diff --git a/IDEHelper/Backend/BeIRCodeGen.cpp b/IDEHelper/Backend/BeIRCodeGen.cpp index 3bc86c34..98f8011b 100644 --- a/IDEHelper/Backend/BeIRCodeGen.cpp +++ b/IDEHelper/Backend/BeIRCodeGen.cpp @@ -2270,6 +2270,11 @@ void BeIRCodeGen::HandleNextCmd() mSavedDebugLocs.pop_back(); } break; + case BfIRCmd_DupDebugLocation: + { + mBeModule->DupCurrentDebugLocation(); + } + break; case BfIRCmd_ClearDebugLocation: { mBeModule->SetCurrentDebugLocation(NULL); diff --git a/IDEHelper/Backend/BeModule.cpp b/IDEHelper/Backend/BeModule.cpp index 30c86753..635d04c4 100644 --- a/IDEHelper/Backend/BeModule.cpp +++ b/IDEHelper/Backend/BeModule.cpp @@ -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(); + 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(); diff --git a/IDEHelper/Backend/BeModule.h b/IDEHelper/Backend/BeModule.h index e220b41f..0ca7d7f5 100644 --- a/IDEHelper/Backend/BeModule.h +++ b/IDEHelper/Backend/BeModule.h @@ -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();