There are two ways to map a variable to its lexical scope. Lexical scope information...
authorDevang Patel <dpatel@apple.com>
Wed, 20 Jul 2011 22:18:50 +0000 (22:18 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 20 Jul 2011 22:18:50 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135629 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DebugInfo.h
lib/Analysis/DebugInfo.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index 152d11ef93a68ad27ea45aa5aa5ad5cbf4413cdd..929dd1d13a7fdb8976bf444a6e6ef4ee67c9c14c 100644 (file)
@@ -614,6 +614,8 @@ namespace llvm {
       return (getUnsignedField(6) & FlagArtificial) != 0;
     }
 
+    /// getInlinedAt - If this variable is inlined then return inline location.
+    MDNode *getInlinedAt();
 
     /// Verify - Verify that a variable descriptor is well formed.
     bool Verify() const;
index 4dcf04ef2163875c1d48ed9abf41044a08dd7fa5..dd85a4fcc80cad8337b1b93539ffbdb599e63b04 100644 (file)
@@ -116,6 +116,12 @@ unsigned DIVariable::getNumAddrElements() const {
   return DbgNode->getNumOperands()-8;
 }
 
+/// getInlinedAt - If this variable is inlined then return inline location.
+MDNode *DIVariable::getInlinedAt() {
+  if (getVersion() <= llvm::LLVMDebugVersion9)
+    return NULL;
+  return dyn_cast_or_null<MDNode>(DbgNode->getOperand(7));
+}
 
 //===----------------------------------------------------------------------===//
 // Predicates
index d427e287af89db2ce974417099c2265c135580ac..30d63991ea0e1e012784231bff8c4e56421a4592 100644 (file)
@@ -1410,8 +1410,16 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
     if (DV.getTag() == dwarf::DW_TAG_arg_variable &&
         DISubprogram(DV.getContext()).describes(MF->getFunction()))
       Scope = CurrentFnDbgScope;
-    else
-      Scope = findDbgScope(MInsn->getDebugLoc());
+    else {
+      if (DV.getVersion() <= LLVMDebugVersion9)
+        Scope = findDbgScope(MInsn->getDebugLoc());
+      else {
+        if (MDNode *IA = DV.getInlinedAt())
+          Scope = InlinedDbgScopeMap.lookup(DebugLoc::getFromDILocation(IA));
+        else
+          Scope = DbgScopeMap.lookup(cast<MDNode>(DV->getOperand(1)));
+      }
+    }
     // If variable scope is not found then skip this variable.
     if (!Scope)
       continue;