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

Fixed an errorVReg relto issue

This commit is contained in:
Brian Fiete 2021-10-13 12:07:51 -07:00
parent 9ac84e12e9
commit 1e3d0308bf

View file

@ -9627,12 +9627,14 @@ bool BeMCContext::DoLegalization()
else
{
// This may be a local variable that failed to be assigned to a reg, create a scratch local with a forced reg
auto scratchReg = AllocVirtualReg(errorVRegInfo->mType, 2, false);
auto scratchVRegInfo = mVRegInfo[scratchReg.mVRegIdx];
auto errorVReg = BeMCOperand::FromVReg(rmInfo.mErrorVReg);
auto errorVRegLoad = BeMCOperand::ToLoad(errorVReg);
if ((vregInfo->mRelTo == errorVReg) || (vregInfo->mRelOffset == errorVReg))
{
auto scratchReg = AllocVirtualReg(errorVRegInfo->mType, 2, false);
auto scratchVRegInfo = mVRegInfo[scratchReg.mVRegIdx];
CreateDefineVReg(scratchReg, instIdx++);
AllocInst(BeMCInstKind_Mov, scratchReg, errorVReg, instIdx++);
isFinalRun = false;
@ -9653,6 +9655,32 @@ bool BeMCContext::DoLegalization()
vregInfo->mRelOffset.mVRegIdx = scratchReg.mVRegIdx;
}
}
else if ((vregInfo->mRelTo == errorVRegLoad) || (vregInfo->mRelOffset == errorVRegLoad))
{
auto scratchType = GetType(errorVRegLoad);
auto scratchReg = AllocVirtualReg(scratchType, 2, false);
auto scratchVRegInfo = mVRegInfo[scratchReg.mVRegIdx];
CreateDefineVReg(scratchReg, instIdx++);
AllocInst(BeMCInstKind_Mov, scratchReg, errorVRegLoad, instIdx++);
isFinalRun = false;
if (debugging)
OutputDebugStrF(" RM failed, scratch vreg\n");
vregExprChangeSet.Add(scratchReg.mVRegIdx);
if (vregInfo->mRelTo == errorVRegLoad)
{
scratchVRegInfo->mForceReg = true;
CheckForce(scratchVRegInfo);
vregInfo->mRelTo = scratchReg;
}
else if (vregInfo->mRelOffset == errorVRegLoad)
{
scratchVRegInfo->mForceReg = true;
CheckForce(scratchVRegInfo);
vregInfo->mRelOffset = scratchReg;
}
}
else
{
// This should be impossible - a previous def for an inner expr should have caught this case
@ -15906,7 +15934,7 @@ void BeMCContext::Generate(BeFunction* function)
mDbgPreferredRegs[32] = X64Reg_R8;*/
//mDbgPreferredRegs[8] = X64Reg_RAX;
//mDebugging = (function->mName == "?DrawCard@Stats@NecroCard@bf@@QEAAX_N@Z");
mDebugging = (function->mName == "?PopulateComboBox$ny@PropertyPanel@Editor@Cobalt@bf@@QEAAXPEAVMenu@widgets@Beefy@4@@Z");
// || (function->mName == "?MethodA@TestProgram@BeefTest@bf@@CAXXZ");
// || (function->mName == "?Hey@Blurg@bf@@SAXXZ")
// ;