DebugInfo: Sink DwarfDebug::addNonArgumentScopeVariable into DwarfFile.
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 23 Oct 2014 22:04:30 +0000 (22:04 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 23 Oct 2014 22:04:30 +0000 (22:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220520 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 151790ccfe837dfcfb93227e094cdb1ed779eb65..29685abab48a3d3db980963a6a0db16a84240715 100644 (file)
@@ -770,7 +770,7 @@ DbgVariable *DwarfDebug::getExistingAbstractVariable(const DIVariable &DV) {
 void DwarfDebug::createAbstractVariable(const DIVariable &Var,
                                         LexicalScope *Scope) {
   auto AbsDbgVariable = make_unique<DbgVariable>(Var, DIExpression(), this);
 void DwarfDebug::createAbstractVariable(const DIVariable &Var,
                                         LexicalScope *Scope) {
   auto AbsDbgVariable = make_unique<DbgVariable>(Var, DIExpression(), this);
-  addNonArgumentScopeVariable(Scope, AbsDbgVariable.get());
+  InfoHolder.addNonArgumentScopeVariable(Scope, AbsDbgVariable.get());
   AbstractVariables[Var] = std::move(AbsDbgVariable);
 }
 
   AbstractVariables[Var] = std::move(AbsDbgVariable);
 }
 
@@ -1256,39 +1256,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
 void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
   if (InfoHolder.addCurrentFnArgument(Var, LS))
     return;
 void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
   if (InfoHolder.addCurrentFnArgument(Var, LS))
     return;
-  addNonArgumentScopeVariable(LS, Var);
-}
-
-void DwarfDebug::addNonArgumentScopeVariable(LexicalScope *LS,
-                                             DbgVariable *Var) {
-  SmallVectorImpl<DbgVariable *> &Vars = ScopeVariables[LS];
-  DIVariable DV = Var->getVariable();
-  // Variables with positive arg numbers are parameters.
-  if (unsigned ArgNum = DV.getArgNumber()) {
-    // Keep all parameters in order at the start of the variable list to ensure
-    // function types are correct (no out-of-order parameters)
-    //
-    // This could be improved by only doing it for optimized builds (unoptimized
-    // builds have the right order to begin with), searching from the back (this
-    // would catch the unoptimized case quickly), or doing a binary search
-    // rather than linear search.
-    SmallVectorImpl<DbgVariable *>::iterator I = Vars.begin();
-    while (I != Vars.end()) {
-      unsigned CurNum = (*I)->getVariable().getArgNumber();
-      // A local (non-parameter) variable has been found, insert immediately
-      // before it.
-      if (CurNum == 0)
-        break;
-      // A later indexed parameter has been found, insert immediately before it.
-      if (CurNum > ArgNum)
-        break;
-      ++I;
-    }
-    Vars.insert(I, Var);
-    return;
-  }
-
-  Vars.push_back(Var);
+  InfoHolder.addNonArgumentScopeVariable(LS, Var);
 }
 
 // Gather and emit post-function debug information.
 }
 
 // Gather and emit post-function debug information.
index ec5618f5da701f72f66f99f8fa6086f0dc12f6c2..d1fae7285f5f777032d19df0827a68f9ade12261 100644 (file)
@@ -334,7 +334,6 @@ class DwarfDebug : public AsmPrinterHandler {
   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
 
   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
 
   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
-  void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
 
   const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
     return InfoHolder.getUnits();
 
   const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
     return InfoHolder.getUnits();
index 7ad28225e9642c14cd672af2843b6b8c2a55d509..6b3d148ee06dc5135ca2e543edbe06ddf3231e5f 100644 (file)
@@ -176,4 +176,36 @@ bool DwarfFile::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
   CurrentFnArguments[ArgNo - 1] = Var;
   return true;
 }
   CurrentFnArguments[ArgNo - 1] = Var;
   return true;
 }
+
+void DwarfFile::addNonArgumentScopeVariable(LexicalScope *LS,
+                                            DbgVariable *Var) {
+  SmallVectorImpl<DbgVariable *> &Vars = DD.getScopeVariables()[LS];
+  DIVariable DV = Var->getVariable();
+  // Variables with positive arg numbers are parameters.
+  if (unsigned ArgNum = DV.getArgNumber()) {
+    // Keep all parameters in order at the start of the variable list to ensure
+    // function types are correct (no out-of-order parameters)
+    //
+    // This could be improved by only doing it for optimized builds (unoptimized
+    // builds have the right order to begin with), searching from the back (this
+    // would catch the unoptimized case quickly), or doing a binary search
+    // rather than linear search.
+    auto I = Vars.begin();
+    while (I != Vars.end()) {
+      unsigned CurNum = (*I)->getVariable().getArgNumber();
+      // A local (non-parameter) variable has been found, insert immediately
+      // before it.
+      if (CurNum == 0)
+        break;
+      // A later indexed parameter has been found, insert immediately before it.
+      if (CurNum > ArgNum)
+        break;
+      ++I;
+    }
+    Vars.insert(I, Var);
+    return;
+  }
+
+  Vars.push_back(Var);
+}
 }
 }
index ce12f1246cdec94e9ea08cfd3cf5a5fa0556294e..0ce9072fb1ee48a139a20014ea0b7fba221a1b83 100644 (file)
@@ -85,6 +85,7 @@ public:
   DwarfStringPool &getStringPool() { return StrPool; }
 
   bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
   DwarfStringPool &getStringPool() { return StrPool; }
 
   bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
+  void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
 };
 }
 #endif
 };
 }
 #endif