[llvm-commits] [llvm] r137637 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h

Devang Patel dpatel at apple.com
Mon Aug 15 12:01:20 PDT 2011


Author: dpatel
Date: Mon Aug 15 14:01:20 2011
New Revision: 137637

URL: http://llvm.org/viewvc/llvm-project?rev=137637&view=rev
Log:
Simplify mapping to variable from its abstract variable info.
When a variable is inlined multiple places, abstract variable keeps name, location, type etc.. info and all other concreate instances of the variable directly refers to abstract variable.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=137637&r1=137636&r2=137637&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 15 14:01:20 2011
@@ -383,21 +383,15 @@
   // Define variable debug information entry.
   DIE *VariableDie = new DIE(Tag);
   CompileUnit *VariableCU = getCompileUnit(DV->getVariable());
-  DIE *AbsDIE = NULL;
-  DenseMap<const DbgVariable *, const DbgVariable *>::iterator
-    V2AVI = VarToAbstractVarMap.find(DV);
-  if (V2AVI != VarToAbstractVarMap.end())
-    AbsDIE = V2AVI->second->getDIE();
-
+  DbgVariable *AbsVar = DV->getAbstractVariable();
+  DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : NULL;
   if (AbsDIE)
     VariableCU->addDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin,
-                       dwarf::DW_FORM_ref4, AbsDIE);
+                            dwarf::DW_FORM_ref4, AbsDIE);
   else {
-    VariableCU->addString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string,
-                          Name);
+    VariableCU->addString(VariableDie, dwarf::DW_AT_name, 
+                          dwarf::DW_FORM_string, Name);
     VariableCU->addSourceLine(VariableDie, DV->getVariable());
-
-    // Add variable type.
     VariableCU->addType(VariableDie, DV->getType());
   }
 
@@ -812,7 +806,7 @@
       for (unsigned I = 0; I != E; ++I) {
         DIVariable DV(NMD->getOperand(I));
         if (!DV.Verify()) continue;
-        Variables.push_back(DbgVariable(DV));
+        Variables.push_back(DbgVariable(DV, NULL));
       }
 
       // Construct subprogram DIE and add variables DIEs.
@@ -907,7 +901,7 @@
   if (!Scope)
     return NULL;
 
-  AbsDbgVariable = new DbgVariable(Var);
+  AbsDbgVariable = new DbgVariable(Var, NULL);
   addScopeVariable(Scope, AbsDbgVariable);
   AbstractVariables[Var] = AbsDbgVariable;
   return AbsDbgVariable;
@@ -958,14 +952,12 @@
       continue;
 
     DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
-    DbgVariable *RegVar = new DbgVariable(DV);
+    DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable);
     recordVariableFrameIndex(RegVar, VP.first);
     if (!addCurrentFnArgument(MF, RegVar, Scope))
       addScopeVariable(Scope, RegVar);
-    if (AbsDbgVariable) {
+    if (AbsDbgVariable)
       recordVariableFrameIndex(AbsDbgVariable, VP.first);
-      VarToAbstractVarMap[RegVar] = AbsDbgVariable;
-    }
   }
 }
 
@@ -1049,13 +1041,12 @@
 
     Processed.insert(DV);
     assert(MInsn->isDebugValue() && "History must begin with debug value");
-    DbgVariable *RegVar = new DbgVariable(DV);
+    DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc());
+    DbgVariable *RegVar = new DbgVariable(DV, AbsVar);
     if (!addCurrentFnArgument(MF, RegVar, Scope))
       addScopeVariable(Scope, RegVar);
-    if (DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc())) {
+    if (AbsVar)
       DbgVariableToDbgInstMap[AbsVar] = MInsn;
-      VarToAbstractVarMap[RegVar] = AbsVar;
-    }
 
     // Simple ranges that are fully coalesced.
     if (History.size() <= 1 || (History.size() == 2 &&
@@ -1113,7 +1104,7 @@
       if (!DV || !Processed.insert(DV))
         continue;
       if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext()))
-        addScopeVariable(Scope, new DbgVariable(DV));
+        addScopeVariable(Scope, new DbgVariable(DV, NULL));
     }
   }
 }
@@ -1455,7 +1446,7 @@
           if (!DV || !ProcessedVars.insert(DV))
             continue;
           if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))
-            addScopeVariable(Scope, new DbgVariable(DV));
+            addScopeVariable(Scope, new DbgVariable(DV, NULL));
         }
       }
     }
@@ -1481,7 +1472,6 @@
   ScopeVariables.clear();
   DeleteContainerPointers(CurrentFnArguments);
   DbgVariableToFrameIndexMap.clear();
-  VarToAbstractVarMap.clear();
   DbgVariableToDbgInstMap.clear();
   UserVariables.clear();
   DbgValues.clear();

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=137637&r1=137636&r2=137637&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 15 14:01:20 2011
@@ -125,9 +125,11 @@
   DIVariable Var;                    // Variable Descriptor.
   DIE *TheDIE;                       // Variable DIE.
   unsigned DotDebugLocOffset;        // Offset in DotDebugLocEntries.
+  DbgVariable *AbsVar;               // Corresponding Abstract variable, if any.
 public:
   // AbsVar may be NULL.
-  DbgVariable(DIVariable V) : Var(V), TheDIE(0), DotDebugLocOffset(~0U) {}
+  DbgVariable(DIVariable V, DbgVariable *AV) 
+    : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV) {}
 
   // Accessors.
   DIVariable getVariable()           const { return Var; }
@@ -136,6 +138,7 @@
   void setDotDebugLocOffset(unsigned O)    { DotDebugLocOffset = O; }
   unsigned getDotDebugLocOffset()    const { return DotDebugLocOffset; }
   StringRef getName()                const { return Var.getName(); }
+  DbgVariable *getAbstractVariable() const { return AbsVar; }
   // Translate tag to proper Dwarf tag.  
   unsigned getTag()                  const { 
     if (Var.getTag() == dwarf::DW_TAG_arg_variable)
@@ -236,10 +239,6 @@
   /// idetifies corresponding .debug_loc entry offset.
   SmallPtrSet<const DIE *, 4> UseDotDebugLocEntry;
 
-  /// VarToAbstractVarMap - Maps DbgVariable with corresponding Abstract
-  /// DbgVariable, if any.
-  DenseMap<const DbgVariable *, const DbgVariable *> VarToAbstractVarMap;
-
   /// InliendSubprogramDIEs - Collection of subprgram DIEs that are marked
   /// (at the end of the module) as DW_AT_inline.
   SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;





More information about the llvm-commits mailing list