1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed debug variable definition ranges

This commit is contained in:
Brian Fiete 2020-02-29 12:45:44 -08:00
parent cb6a6484eb
commit e508b8ded7

View file

@ -6096,6 +6096,8 @@ void BeMCContext::VRegSetInitialized(BeMCBlock* mcBlock, BeMCInst* inst, const B
int insertIdx = FindSafeInstInsertPos(*mInsertInstIdxRef); int insertIdx = FindSafeInstInsertPos(*mInsertInstIdxRef);
AllocInst(BeMCInstKind_Def, operand, insertIdx); AllocInst(BeMCInstKind_Def, operand, insertIdx);
vregInfo->mDefOnFirstUse = false; vregInfo->mDefOnFirstUse = false;
if (insertIdx <= *mInsertInstIdxRef)
(*mInsertInstIdxRef)++;
} }
if (vregInfo->mRelTo) if (vregInfo->mRelTo)
@ -6156,6 +6158,11 @@ void BeMCContext::InitializedPassHelper(BeMCBlock* mcBlock, BeVTrackingGenContex
//OutputDebugStrF("InitializedPassHelper %@\n", vregsInitialized.mList); //OutputDebugStrF("InitializedPassHelper %@\n", vregsInitialized.mList);
if (mDebugging)
{
NOP;
}
mActiveBlock = mcBlock; mActiveBlock = mcBlock;
for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++) for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++)
{ {
@ -11701,12 +11708,14 @@ void BeMCContext::DoCodeEmission()
int hotJumpLen = 5; int hotJumpLen = 5;
int funcCodePos = 0; int funcCodePos = 0;
Array<BeDbgVariable*> deferredGapEnds;
BeVTrackingList* vregsLive = mLivenessContext.AllocEmptyList(); BeVTrackingList* vregsLive = mLivenessContext.AllocEmptyList();
BeVTrackingList* vregsInitialized = mVRegInitializedContext.AllocEmptyList(); BeVTrackingList* vregsInitialized = mVRegInitializedContext.AllocEmptyList();
for (auto mcBlock : mBlocks) for (auto mcBlock : mBlocks)
{ {
for (auto inst : mcBlock->mInstructions) for (auto inst : mcBlock->mInstructions)
{ {
if (mDebugging) if (mDebugging)
{ {
ToString(inst, dbgStr, true, true); ToString(inst, dbgStr, true, true);
@ -11728,6 +11737,19 @@ void BeMCContext::DoCodeEmission()
} }
} }
} }
while (!deferredGapEnds.IsEmpty())
{
BeDbgVariable* dbgVar = deferredGapEnds.back();
deferredGapEnds.pop_back();
auto& range = dbgVar->mGaps.back();
range.mLength = funcCodePos - range.mOffset;
if (range.mLength <= 0)
{
dbgVar->mGaps.pop_back();
}
}
if ((inst->mKind == BeMCInstKind_LifetimeEnd) || (inst->mKind == BeMCInstKind_LifetimeExtend)) if ((inst->mKind == BeMCInstKind_LifetimeEnd) || (inst->mKind == BeMCInstKind_LifetimeExtend))
{ {
@ -11845,11 +11867,7 @@ void BeMCContext::DoCodeEmission()
// We have to check for this because it's possible we get multiple adds // We have to check for this because it's possible we get multiple adds
if (range.mLength == -1) if (range.mLength == -1)
{ {
range.mLength = funcCodePos - range.mOffset; deferredGapEnds.Add(dbgVar);
if (range.mLength <= 0)
{
dbgVar->mGaps.pop_back();
}
} }
if (mDebugging) if (mDebugging)
@ -14691,7 +14709,7 @@ void BeMCContext::Generate(BeFunction* function)
mDbgPreferredRegs[32] = X64Reg_R8;*/ mDbgPreferredRegs[32] = X64Reg_R8;*/
//mDbgPreferredRegs[8] = X64Reg_RAX; //mDbgPreferredRegs[8] = X64Reg_RAX;
//mDebugging = function->mName == "?Unwrap@?$Result@Tint@@@System@bf@@AEAATint@@XZ"; //mDebugging = function->mName == "?Hey@Blurg@bf@@SAXXZ";
//"?ColorizeCodeString@IDEUtils@IDE@bf@@SAXPEAVString@System@3@W4CodeKind@123@@Z"; //"?ColorizeCodeString@IDEUtils@IDE@bf@@SAXPEAVString@System@3@W4CodeKind@123@@Z";
//"?Main@Program@bf@@CAHPEAV?$Array1@PEAVString@System@bf@@@System@2@@Z"; //"?Main@Program@bf@@CAHPEAV?$Array1@PEAVString@System@bf@@@System@2@@Z";