1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +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(mCurMethodState->mIRInitBlock);
typedVal = BfTypedValue(mBfIRBuilder->CreateBitCast(allocaInst, mBfIRBuilder->MapType(arrayType)), arrayType);
mBfIRBuilder->ClearDebugLocation_Last();
mBfIRBuilder->SetInsertPoint(prevBlock); 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);