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:
parent
d42cbbb6a9
commit
5de6373b99
1 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue