mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Avoid emitting bitCast in head block
This commit is contained in:
parent
d10951527a
commit
3322211048
1 changed files with 13 additions and 4 deletions
|
@ -8984,10 +8984,19 @@ BfIRValue BfModule::AllocFromType(BfType* type, const BfAllocTarget& allocTarget
|
||||||
mBfIRBuilder->ClearDebugLocation(allocaInst);
|
mBfIRBuilder->ClearDebugLocation(allocaInst);
|
||||||
auto allocaBlock = mBfIRBuilder->GetInsertBlock();
|
auto allocaBlock = mBfIRBuilder->GetInsertBlock();
|
||||||
mBfIRBuilder->SetAllocaAlignment(allocaInst, allocAlign);
|
mBfIRBuilder->SetAllocaAlignment(allocaInst, allocAlign);
|
||||||
auto typedVal = BfTypedValue(mBfIRBuilder->CreateBitCast(allocaInst, mBfIRBuilder->MapType(arrayType)), arrayType);
|
|
||||||
mBfIRBuilder->ClearDebugLocation_Last();
|
BfTypedValue typedVal;
|
||||||
if (!isDynAlloc)
|
if (!isDynAlloc)
|
||||||
mBfIRBuilder->SetInsertPoint(prevBlock);
|
{
|
||||||
|
mBfIRBuilder->SetInsertPoint(mCurMethodState->mIRInitBlock);
|
||||||
|
typedVal = BfTypedValue(mBfIRBuilder->CreateBitCast(allocaInst, mBfIRBuilder->MapType(arrayType)), arrayType);
|
||||||
|
mBfIRBuilder->ClearDebugLocation_Last();
|
||||||
|
mBfIRBuilder->SetInsertPoint(prevBlock);
|
||||||
|
allocaBlock = mCurMethodState->mIRInitBlock;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
typedVal = BfTypedValue(mBfIRBuilder->CreateBitCast(allocaInst, mBfIRBuilder->MapType(arrayType)), arrayType);
|
||||||
|
|
||||||
if (!noDtorCall)
|
if (!noDtorCall)
|
||||||
AddStackAlloc(typedVal, BfIRValue(), NULL, scopeData, false, true, allocaBlock);
|
AddStackAlloc(typedVal, BfIRValue(), NULL, scopeData, false, true, allocaBlock);
|
||||||
InitTypeInst(typedVal, scopeData, zeroMemory, sizeValue);
|
InitTypeInst(typedVal, scopeData, zeroMemory, sizeValue);
|
||||||
|
@ -20277,7 +20286,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurMethodState->mIRExitBlock)
|
if (mCurMethodState->mIRExitBlock)
|
||||||
{
|
{
|
||||||
for (auto preExitBlock : mCurMethodState->mHeadScope.mAtEndBlocks)
|
for (auto preExitBlock : mCurMethodState->mHeadScope.mAtEndBlocks)
|
||||||
mBfIRBuilder->MoveBlockToEnd(preExitBlock);
|
mBfIRBuilder->MoveBlockToEnd(preExitBlock);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue