[llvm] r210961 - DebugInfo: Remove some extra handling of abstract variables and instead rely solely on the delayed handling introduced in r210946

David Blaikie dblaikie at gmail.com
Fri Jun 13 16:52:55 PDT 2014


Author: dblaikie
Date: Fri Jun 13 18:52:55 2014
New Revision: 210961

URL: http://llvm.org/viewvc/llvm-project?rev=210961&view=rev
Log:
DebugInfo: Remove some extra handling of abstract variables and instead rely solely on the delayed handling introduced in r210946

Now that we handle finding abstract variables at the end of the module,
remove the upfront handling and just ensure the abstract variable is
built when necessary.

In theory we could have a split implementation, where inlined variables
are immediately constructed referencing the abstract definition, and
concrete variables are delayed - but let's go with one solution for now
unless there's a reason not to.

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=210961&r1=210960&r2=210961&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jun 13 18:52:55 2014
@@ -865,7 +865,7 @@ void DwarfDebug::collectDeadVariables()
         for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
           DIVariable DV(Variables.getElement(vi));
           assert(DV.isVariable());
-          DbgVariable NewVar(DV, nullptr, this);
+          DbgVariable NewVar(DV, this);
           auto VariableDie = SPCU->constructVariableDIE(NewVar);
           SPCU->applyVariableAttributes(NewVar, *VariableDie);
           SPDIE->addChild(std::move(VariableDie));
@@ -1086,32 +1086,31 @@ DbgVariable *DwarfDebug::getExistingAbst
   return getExistingAbstractVariable(DV, Cleansed);
 }
 
-DbgVariable *DwarfDebug::createAbstractVariable(DIVariable &Var,
-                                                LexicalScope *Scope) {
-  auto AbsDbgVariable = make_unique<DbgVariable>(Var, nullptr, this);
+void DwarfDebug::createAbstractVariable(const DIVariable &Var,
+                                        LexicalScope *Scope) {
+  auto AbsDbgVariable = make_unique<DbgVariable>(Var, this);
   addScopeVariable(Scope, AbsDbgVariable.get());
-  return (AbstractVariables[Var] = std::move(AbsDbgVariable)).get();
+  AbstractVariables[Var] = std::move(AbsDbgVariable);
 }
 
-DbgVariable *DwarfDebug::getOrCreateAbstractVariable(DIVariable &DV,
-                                                     const MDNode *ScopeNode) {
+void DwarfDebug::ensureAbstractVariableIsCreated(const DIVariable &DV,
+                                                 const MDNode *ScopeNode) {
   DIVariable Cleansed = DV;
-  if (DbgVariable *Var = getExistingAbstractVariable(DV, Cleansed))
-    return Var;
+  if (getExistingAbstractVariable(DV, Cleansed))
+    return;
 
-  return createAbstractVariable(Cleansed,
-                                LScopes.getOrCreateAbstractScope(ScopeNode));
+  createAbstractVariable(Cleansed, LScopes.getOrCreateAbstractScope(ScopeNode));
 }
 
-DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &DV,
-                                              const MDNode *ScopeNode) {
+void
+DwarfDebug::ensureAbstractVariableIsCreatedIfScoped(const DIVariable &DV,
+                                                    const MDNode *ScopeNode) {
   DIVariable Cleansed = DV;
-  if (DbgVariable *Var = getExistingAbstractVariable(DV, Cleansed))
-    return Var;
+  if (getExistingAbstractVariable(DV, Cleansed))
+    return;
 
   if (LexicalScope *Scope = LScopes.findAbstractScope(ScopeNode))
-    return createAbstractVariable(Cleansed, Scope);
-  return nullptr;
+    createAbstractVariable(Cleansed, Scope);
 }
 
 // If Var is a current function argument then add it to CurrentFnArguments list.
@@ -1150,9 +1149,8 @@ void DwarfDebug::collectVariableInfoFrom
     if (!Scope)
       continue;
 
-    DbgVariable *AbsDbgVariable =
-        findAbstractVariable(DV, Scope->getScopeNode());
-    ConcreteVariables.push_back(make_unique<DbgVariable>(DV, AbsDbgVariable, this));
+    ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
+    ConcreteVariables.push_back(make_unique<DbgVariable>(DV, this));
     DbgVariable *RegVar = ConcreteVariables.back().get();
     RegVar->setFrameIndex(VI.Slot);
     addScopeVariable(Scope, RegVar);
@@ -1220,8 +1218,8 @@ DwarfDebug::collectVariableInfo(SmallPtr
     Processed.insert(DV);
     const MachineInstr *MInsn = Ranges.front().first;
     assert(MInsn->isDebugValue() && "History must begin with debug value");
-    DbgVariable *AbsVar = findAbstractVariable(DV, Scope->getScopeNode());
-    ConcreteVariables.push_back(make_unique<DbgVariable>(MInsn, AbsVar, this));
+    ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
+    ConcreteVariables.push_back(make_unique<DbgVariable>(MInsn, this));
     DbgVariable *RegVar = ConcreteVariables.back().get();
     addScopeVariable(Scope, RegVar);
 
@@ -1278,8 +1276,8 @@ DwarfDebug::collectVariableInfo(SmallPtr
     if (!Processed.insert(DV))
       continue;
     if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext())) {
-      ConcreteVariables.push_back(make_unique<DbgVariable>(
-          DV, findAbstractVariable(DV, Scope->getScopeNode()), this));
+      ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
+      ConcreteVariables.push_back(make_unique<DbgVariable>(DV, this));
       addScopeVariable(Scope, ConcreteVariables.back().get());
     }
   }
@@ -1563,7 +1561,7 @@ void DwarfDebug::endFunction(const Machi
       assert(DV && DV.isVariable());
       if (!ProcessedVars.insert(DV))
         continue;
-      getOrCreateAbstractVariable(DV, DV.getContext());
+      ensureAbstractVariableIsCreated(DV, DV.getContext());
     }
     constructAbstractSubprogramScopeDIE(TheCU, AScope);
   }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=210961&r1=210960&r2=210961&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Jun 13 18:52:55 2014
@@ -72,25 +72,21 @@ class DbgVariable {
   DIVariable Var;             // Variable Descriptor.
   DIE *TheDIE;                // Variable DIE.
   unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
-  DbgVariable *AbsVar;        // Corresponding Abstract variable, if any.
   const MachineInstr *MInsn;  // DBG_VALUE instruction of the variable.
   int FrameIndex;
   DwarfDebug *DD;
 
 public:
   /// Construct a DbgVariable from a DIVariable.
-  /// AbstractVar may be NULL.
-  DbgVariable(DIVariable V, DbgVariable *AbstractVar, DwarfDebug *DD)
-      : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), AbsVar(AbstractVar),
-        MInsn(nullptr), FrameIndex(~0), DD(DD) {}
+  DbgVariable(DIVariable V, DwarfDebug *DD)
+      : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(nullptr),
+        FrameIndex(~0), DD(DD) {}
 
   /// Construct a DbgVariable from a DEBUG_VALUE.
   /// AbstractVar may be NULL.
-  DbgVariable(const MachineInstr *DbgValue, DbgVariable *AbstractVar,
-              DwarfDebug *DD)
-    : Var(DbgValue->getDebugVariable()),
-      TheDIE(nullptr), DotDebugLocOffset(~0U), AbsVar(AbstractVar),
-      MInsn(DbgValue), FrameIndex(~0), DD(DD) {}
+  DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
+      : Var(DbgValue->getDebugVariable()), TheDIE(nullptr),
+        DotDebugLocOffset(~0U), MInsn(DbgValue), FrameIndex(~0), DD(DD) {}
 
   // Accessors.
   DIVariable getVariable() const { return Var; }
@@ -99,7 +95,6 @@ public:
   void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
   unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
   StringRef getName() const { return Var.getName(); }
-  DbgVariable *getAbstractVariable() const { return AbsVar; }
   const MachineInstr *getMInsn() const { return MInsn; }
   int getFrameIndex() const { return FrameIndex; }
   void setFrameIndex(int FI) { FrameIndex = FI; }
@@ -347,10 +342,11 @@ class DwarfDebug : public AsmPrinterHand
   DbgVariable *getExistingAbstractVariable(const DIVariable &DV,
                                            DIVariable &Cleansed);
   DbgVariable *getExistingAbstractVariable(const DIVariable &DV);
-  DbgVariable *createAbstractVariable(DIVariable &DV, LexicalScope *Scope);
-  DbgVariable *getOrCreateAbstractVariable(DIVariable &Var,
-                                           const MDNode *Scope);
-  DbgVariable *findAbstractVariable(DIVariable &Var, const MDNode *Scope);
+  void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
+  void ensureAbstractVariableIsCreated(const DIVariable &Var,
+                                       const MDNode *Scope);
+  void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
+                                               const MDNode *Scope);
 
   /// \brief Find DIE for the given subprogram and attach appropriate
   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global





More information about the llvm-commits mailing list