[llvm] r220453 - [DebugInfo] Sink DwarfDebug::addCurrentFnArgument down into DwarfFile.

David Blaikie dblaikie at gmail.com
Wed Oct 22 17:16:06 PDT 2014


Author: dblaikie
Date: Wed Oct 22 19:16:05 2014
New Revision: 220453

URL: http://llvm.org/viewvc/llvm-project?rev=220453&view=rev
Log:
[DebugInfo] Sink DwarfDebug::addCurrentFnArgument down into DwarfFile.

Variable handling will be sunk into DwarfFile so that abstract variables
and the like can be shared across multiple CUs (to handle cross-CU
inlining, for example).

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    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=220453&r1=220452&r2=220453&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 22 19:16:05 2014
@@ -794,29 +794,6 @@ DwarfDebug::ensureAbstractVariableIsCrea
     createAbstractVariable(Cleansed, Scope);
 }
 
-// If Var is a current function argument then add it to CurrentFnArguments list.
-bool DwarfDebug::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;
-
-  size_t Size = CurrentFnArguments.size();
-  if (Size == 0)
-    CurrentFnArguments.resize(CurFn->getFunction()->arg_size());
-  // llvm::Function argument size is not good indicator of how many
-  // arguments does the function have at source level.
-  if (ArgNo > Size)
-    CurrentFnArguments.resize(ArgNo * 2);
-  assert(!CurrentFnArguments[ArgNo - 1]);
-  CurrentFnArguments[ArgNo - 1] = Var;
-  return true;
-}
-
 // Collect variable information from side table maintained by MMI.
 void DwarfDebug::collectVariableInfoFromMMITable(
     SmallPtrSetImpl<const MDNode *> &Processed) {
@@ -1277,7 +1254,7 @@ void DwarfDebug::beginFunction(const Mac
 }
 
 void DwarfDebug::addScopeVariable(LexicalScope *LS, DbgVariable *Var) {
-  if (addCurrentFnArgument(Var, LS))
+  if (InfoHolder.addCurrentFnArgument(Var, LS))
     return;
   addNonArgumentScopeVariable(LS, Var);
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp?rev=220453&r1=220452&r2=220453&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.cpp Wed Oct 22 19:16:05 2014
@@ -70,6 +70,7 @@ void DwarfFile::emitUnits(const MCSymbol
     Asm->OutStreamer.EmitLabel(TheU->getLabelEnd());
   }
 }
+
 // Compute the size and offset for each DIE.
 void DwarfFile::computeSizeAndOffsets() {
   // Offset from the first CU in the debug info section is 0 initially.
@@ -155,4 +156,26 @@ void DwarfFile::emitStrings(const MCSect
                             const MCSection *OffsetSection) {
   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;
+}
 }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h?rev=220453&r1=220452&r2=220453&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfFile.h Wed Oct 22 19:16:05 2014
@@ -24,10 +24,12 @@
 
 namespace llvm {
 class AsmPrinter;
+class DbgVariable;
 class DwarfUnit;
 class DIEAbbrev;
 class MCSymbol;
 class DIE;
+class LexicalScope;
 class StringRef;
 class DwarfDebug;
 class MCSection;
@@ -81,6 +83,8 @@ public:
 
   /// \brief Returns the string pool.
   DwarfStringPool &getStringPool() { return StrPool; }
+
+  bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
 };
 }
 #endif





More information about the llvm-commits mailing list