1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fixed code generation when dereferencing a null constant

This commit is contained in:
Brian Fiete 2020-05-10 06:32:15 -07:00
parent d42cbbb6a9
commit 5de6373b99

View file

@ -2753,6 +2753,15 @@ BeMCOperand BeMCContext::CreateCall(const BeMCOperand &func, const SizedArrayImp
BeMCOperand BeMCContext::CreateLoad(const BeMCOperand& mcTarget)
{
if (mcTarget.mKind == BeMCOperandKind_Immediate_Null)
{
auto fakeType = GetType(mcTarget);
auto fakePtr = AllocVirtualReg(fakeType);
CreateDefineVReg(fakePtr);
AllocInst(BeMCInstKind_Mov, fakePtr, BeMCOperand::FromImmediate(0));
return CreateLoad(fakePtr);
}
BeMCOperand result;
auto loadedTarget = BeMCOperand::ToLoad(mcTarget);