1
0
Fork 0
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:
Brian Fiete 2021-11-05 06:57:41 -07:00
parent d10951527a
commit 3322211048

View file

@ -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);