1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Fixed reusing of inlined debug locations

This commit is contained in:
Brian Fiete 2020-05-13 07:41:08 -07:00
parent f96b1a5d7a
commit 706153348a
3 changed files with 36 additions and 0 deletions

View file

@ -2270,6 +2270,11 @@ void BeIRCodeGen::HandleNextCmd()
mSavedDebugLocs.pop_back();
}
break;
case BfIRCmd_DupDebugLocation:
{
mBeModule->DupCurrentDebugLocation();
}
break;
case BfIRCmd_ClearDebugLocation:
{
mBeModule->SetCurrentDebugLocation(NULL);

View file

@ -2609,6 +2609,9 @@ void BeModule::DoInlining(BeFunction* func)
if (funcInlined.find(inlineFunc) != funcInlined.end())
continue; // Don't recursively inline
// Incase we have multiple inlines from the same location, those need to have unique dbgLocs
callInst->mDbgLoc = DupDebugLocation(callInst->mDbgLoc);
hadInlining = true;
BeInliner inliner;
@ -3096,6 +3099,32 @@ void BeModule::SetCurrentDebugLocation(int line, int column, BeMDNode* dbgScope,
mLastDbgLoc = mCurDbgLoc;
}
BeDbgLoc* BeModule::DupDebugLocation(BeDbgLoc* dbgLoc)
{
if (dbgLoc == NULL)
return dbgLoc;
auto newDbgLoc = mAlloc.Alloc<BeDbgLoc>();
newDbgLoc->mLine = dbgLoc->mLine;
newDbgLoc->mColumn = dbgLoc->mColumn;
newDbgLoc->mDbgScope = dbgLoc->mDbgScope;
newDbgLoc->mDbgInlinedAt = dbgLoc->mDbgInlinedAt;
newDbgLoc->mIdx = mCurDbgLocIdx++;
if ((newDbgLoc->mDbgInlinedAt != NULL) && (!newDbgLoc->mDbgInlinedAt->mHadInline))
{
newDbgLoc->mDbgInlinedAt->mHadInline = true;
}
return newDbgLoc;
}
void BeModule::DupCurrentDebugLocation()
{
mCurDbgLoc = DupDebugLocation(mCurDbgLoc);
mLastDbgLoc = mCurDbgLoc;
}
BeNopInst* BeModule::CreateNop()
{
auto inst = mAlloc.Alloc<BeNopInst>();

View file

@ -2104,6 +2104,8 @@ public:
BeDbgLoc* GetCurrentDebugLocation();
void SetCurrentDebugLocation(BeDbgLoc* dbgLoc);
void SetCurrentDebugLocation(int line, int column, BeMDNode* diScope, BeDbgLoc* diInlinedAt);
BeDbgLoc* DupDebugLocation(BeDbgLoc* dbgLoc);
void DupCurrentDebugLocation();
///
BeNopInst* CreateNop();