[llvm] r220520 - DebugInfo: Sink DwarfDebug::addNonArgumentScopeVariable into DwarfFile.

David Blaikie dblaikie at gmail.com
Thu Oct 23 15:04:30 PDT 2014


Author: dblaikie
Date: Thu Oct 23 17:04:30 2014
New Revision: 220520

URL: http://llvm.org/viewvc/llvm-project?rev=220520&view=rev
Log:
DebugInfo: Sink DwarfDebug::addNonArgumentScopeVariable into DwarfFile.

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=220520&r1=220519&r2=220520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Oct 23 17:04:30 2014
@@ -770,7 +770,7 @@ DbgVariable *DwarfDebug::getExistingAbst
 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);
 }
 
@@ -1256,39 +1256,7 @@ void DwarfDebug::beginFunction(const Mac
 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.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=220520&r1=220519&r2=220520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Oct 23 17:04:30 2014
@@ -334,7 +334,6 @@ class DwarfDebug : public AsmPrinterHand
   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();

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp?rev=220520&r1=220519&r2=220520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp Thu Oct 23 17:04:30 2014
@@ -176,4 +176,36 @@ bool DwarfFile::addCurrentFnArgument(Dbg
   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);
+}
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h?rev=220520&r1=220519&r2=220520&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h Thu Oct 23 17:04:30 2014
@@ -85,6 +85,7 @@ public:
   DwarfStringPool &getStringPool() { return StrPool; }
 
   bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
+  void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
 };
 }
 #endif





More information about the llvm-commits mailing list