Use DebugLoc directly to map inlined functions' instructions to respective lexical...
authorDevang Patel <dpatel@apple.com>
Fri, 15 Jul 2011 21:25:44 +0000 (21:25 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 15 Jul 2011 21:25:44 +0000 (21:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135302 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h

index c5efd99969ae8eeb85f3327d89d50678f45391a2..125e1e86b12fdad29366f625f7f845581e409eac 100644 (file)
@@ -1593,6 +1593,7 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(DebugLoc DL) {
 
   WScope = new DbgScope(NULL, DIDescriptor(Scope), InlinedAt);
   DbgScopeMap.insert(std::make_pair(InlinedAt, WScope));
+  InlinedDbgScopeMap[DebugLoc::getFromDILocation(InlinedAt)] = WScope;
   DbgScope *Parent =
     getOrCreateDbgScope(DebugLoc::getFromDILocation(InlinedAt));
   WScope->setParent(Parent);
@@ -2043,6 +2044,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
   DbgVariableToFrameIndexMap.clear();
   VarToAbstractVarMap.clear();
   DbgVariableToDbgInstMap.clear();
+  InlinedDbgScopeMap.clear();
   DeleteContainerSeconds(DbgScopeMap);
   UserVariables.clear();
   DbgValues.clear();
@@ -2079,10 +2081,10 @@ DbgScope *DwarfDebug::findDbgScope(DebugLoc DL) {
 
   DbgScope *Scope = NULL;
   LLVMContext &Ctx = Asm->MF->getFunction()->getContext();
-  const MDNode *N = DL.getScope(Ctx);
-  if (const MDNode *IA = DL.getInlinedAt(Ctx))
-    N = IA;
-  Scope = DbgScopeMap.lookup(N);
+  if (MDNode *IA = DL.getInlinedAt(Ctx))
+    Scope = InlinedDbgScopeMap.lookup(DebugLoc::getFromDILocation(IA));
+  else
+    Scope = DbgScopeMap.lookup(DL.getScope(Ctx));
   return Scope;
 }
 
index 82b319f16feb181b73ea66173dfc0ed12ff48cdf..b2450064e3d0c272533008fd00c5f14936212274 100644 (file)
@@ -201,9 +201,11 @@ class DwarfDebug {
 
   /// DbgScopeMap - Tracks the scopes in the current function.  Owns the
   /// contained DbgScope*s.
-  ///
   DenseMap<const MDNode *, DbgScope *> DbgScopeMap;
 
+  /// InlinedDbgScopeMap - Tracks inlined function scopes in current function.
+  DenseMap<DebugLoc, DbgScope *> InlinedDbgScopeMap;
+
   /// AbstractScopes - Tracks the abstract scopes a module. These scopes are
   /// not included DbgScopeMap.  AbstractScopes owns its DbgScope*s.
   DenseMap<const MDNode *, DbgScope *> AbstractScopes;