[llvm] r220527 - DebugInfo: Remove DwarfDebug::CurrentFnArguments since we have to handle argument ordering of other arguments (abstract arguments) in the same way and already have code for that too.

David Blaikie dblaikie at gmail.com
Thu Oct 23 15:27:51 PDT 2014


Author: dblaikie
Date: Thu Oct 23 17:27:50 2014
New Revision: 220527

URL: http://llvm.org/viewvc/llvm-project?rev=220527&view=rev
Log:
DebugInfo: Remove DwarfDebug::CurrentFnArguments since we have to handle argument ordering of other arguments (abstract arguments) in the same way and already have code for that too.

While refactoring this code I was confused by both the name I had
introduced (addNonArgumentVariable... but it has all this logic to
handle argument numbering and keep things in order?) and by the
redundancy. Seems when I fixed the misordered inlined argument handling,
I didn't realize it was mostly redundant with the argument ordering code
(which I may've also written, I'm not sure). So let's just rely on the
more general case.

The only oddity in output this produces is that it means when we emit
all the variables for the current function, we don't track when we've
finished the argument variables and are about to start the local
variables and insert DW_AT_unspecified_parameters (for varargs
functions) there. Instead it ends up after the local variables, scopes,
etc. But this isn't invalid and doesn't cause DWARF consumers problems
that I know of... so we'll just go with that because it makes the code
nice & simple.

(though, let's see what the buildbots have to say about this - *crosses
fingers*)

There will be some cleanup commits to follow to remove the now trivial
wrappers, etc.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
    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
    llvm/trunk/test/DebugInfo/varargs.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=220527&r1=220526&r2=220527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu Oct 23 17:27:50 2014
@@ -556,31 +556,21 @@ void DwarfCompileUnit::constructSubprogr
 
   DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
 
-  // Collect arguments for current function.
-  DIE *ObjectPointer = nullptr;
-  for (DbgVariable *ArgDV : DD->getCurrentFnArguments())
-    if (ArgDV)
-      ScopeDIE.addChild(constructVariableDIE(*ArgDV, *Scope, ObjectPointer));
-
   // If this is a variadic function, add an unspecified parameter.
   DITypeArray FnArgs = Sub.getType().getTypeArray();
+
+  // Collect lexical scope children first.
+  // ObjectPointer might be a local (non-argument) local variable if it's a
+  // block's synthetic this pointer.
+  if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, ScopeDIE))
+    addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
+
   // If we have a single element of null, it is a function that returns void.
   // If we have more than one elements and the last one is null, it is a
   // variadic function.
   if (FnArgs.getNumElements() > 1 &&
       !FnArgs.getElement(FnArgs.getNumElements() - 1))
     ScopeDIE.addChild(make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
-
-  // Collect lexical scope children first.
-  // ObjectPointer might be a local (non-argument) local variable if it's a
-  // block's synthetic this pointer.
-  if (DIE *BlockObjPtr = createAndAddScopeChildren(Scope, ScopeDIE)) {
-    assert(!ObjectPointer && "multiple object pointers can't be described");
-    ObjectPointer = BlockObjPtr;
-  }
-
-  if (ObjectPointer)
-    addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
 }
 
 DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=220527&r1=220526&r2=220527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Oct 23 17:27:50 2014
@@ -1254,8 +1254,6 @@ void DwarfDebug::beginFunction(const Mac
 }
 
 void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
-  if (InfoHolder.addCurrentFnArgument(Var, LS))
-    return;
   InfoHolder.addNonArgumentScopeVariable(LS, Var);
 }
 
@@ -1297,7 +1295,6 @@ void DwarfDebug::endFunction(const Machi
   if (TheCU.getCUNode().getEmissionKind() == DIBuilder::LineTablesOnly &&
       LScopes.getAbstractScopesList().empty() && !IsDarwin) {
     assert(ScopeVariables.empty());
-    assert(CurrentFnArguments.empty());
     assert(DbgValues.empty());
     // FIXME: This wouldn't be true in LTO with a -g (with inlining) CU followed
     // by a -gmlt CU. Add a test and remove this assertion.
@@ -1337,7 +1334,6 @@ void DwarfDebug::endFunction(const Machi
   // DbgVariables except those that are also in AbstractVariables (since they
   // can be used cross-function)
   ScopeVariables.clear();
-  CurrentFnArguments.clear();
   DbgValues.clear();
   LabelsBeforeInsn.clear();
   LabelsAfterInsn.clear();

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=220527&r1=220526&r2=220527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Oct 23 17:27:50 2014
@@ -194,9 +194,6 @@ class DwarfDebug : public AsmPrinterHand
   typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
   SectionMapType SectionMap;
 
-  // List of arguments for current function.
-  SmallVector<DbgVariable *, 8> CurrentFnArguments;
-
   LexicalScopes LScopes;
 
   // Collection of abstract subprogram DIEs.
@@ -675,10 +672,6 @@ public:
   SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
     return ProcessedSPNodes;
   }
-
-  SmallVector<DbgVariable *, 8> &getCurrentFnArguments() {
-    return CurrentFnArguments;
-  }
 };
 } // End of namespace llvm
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp?rev=220527&r1=220526&r2=220527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp Thu Oct 23 17:27:50 2014
@@ -155,28 +155,6 @@ void DwarfFile::emitStrings(const MCSect
   StrPool.emit(*Asm, StrSection, OffsetSection);
 }
 
-// If Var is a current function argument then add it to CurrentFnArguments list.
-bool DwarfFile::addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope) {
-  if (Scope->getParent())
-    return false;
-  DIVariable DV = Var->getVariable();
-  if (DV.getTag() != dwarf::DW_TAG_arg_variable)
-    return false;
-  unsigned ArgNo = DV.getArgNumber();
-  if (ArgNo == 0)
-    return false;
-
-  auto &CurrentFnArguments = DD.getCurrentFnArguments();
-
-  // llvm::Function argument size is not good indicator of how many
-  // arguments does the function have at source level.
-  if (ArgNo > CurrentFnArguments.size())
-    CurrentFnArguments.resize(ArgNo * 2);
-  assert(!CurrentFnArguments[ArgNo - 1]);
-  CurrentFnArguments[ArgNo - 1] = Var;
-  return true;
-}
-
 void DwarfFile::addNonArgumentScopeVariable(LexicalScope *LS,
                                             DbgVariable *Var) {
   SmallVectorImpl<DbgVariable *> &Vars = DD.getScopeVariables()[LS];
@@ -200,6 +178,7 @@ void DwarfFile::addNonArgumentScopeVaria
       // A later indexed parameter has been found, insert immediately before it.
       if (CurNum > ArgNum)
         break;
+      assert(CurNum != ArgNum);
       ++I;
     }
     Vars.insert(I, Var);

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h?rev=220527&r1=220526&r2=220527&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h Thu Oct 23 17:27:50 2014
@@ -84,7 +84,6 @@ public:
   /// \brief Returns the string pool.
   DwarfStringPool &getStringPool() { return StrPool; }
 
-  bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
   void addNonArgumentScopeVariable(LexicalScope *LS, DbgVariable *Var);
 };
 }

Modified: llvm/trunk/test/DebugInfo/varargs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/varargs.ll?rev=220527&r1=220526&r2=220527&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/varargs.ll (original)
+++ llvm/trunk/test/DebugInfo/varargs.ll Thu Oct 23 17:27:50 2014
@@ -27,6 +27,10 @@
 ; CHECK-NOT: DW_TAG
 ; CHECK: DW_TAG_formal_parameter
 ; CHECK-NOT: DW_TAG
+; CHECK: DW_TAG_variable
+; CHECK-NOT: DW_TAG
+; CHECK: DW_TAG_variable
+; CHECK-NOT: DW_TAG
 ; CHECK: DW_TAG_unspecified_parameters
 ;
 ; Variadic C++ member function.





More information about the llvm-commits mailing list