[llvm] r206098 - Use dwarf::Tag rather than unsigned for DIE::Tag to make debugging easier.

David Blaikie dblaikie at gmail.com
Fri Apr 11 19:24:04 PDT 2014


Author: dblaikie
Date: Fri Apr 11 21:24:04 2014
New Revision: 206098

URL: http://llvm.org/viewvc/llvm-project?rev=206098&view=rev
Log:
Use dwarf::Tag rather than unsigned for DIE::Tag to make debugging easier.

Nice to be able to just print out the Tag and have the debugger print
dwarf::DW_TAG_subprogram or whatever, rather than an int.

It's a bit finicky (for example DIDescriptor::getTag still returns
unsigned) because some places still handle real dwarf tags + our fake
tags (one day we'll remove the fake tags, hopefully).

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=206098&r1=206097&r2=206098&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Fri Apr 11 21:24:04 2014
@@ -132,8 +132,13 @@ protected:
   ///
   SmallVector<DIEValue *, 12> Values;
 
+protected:
+  DIE()
+      : Offset(0), Size(0), Abbrev((dwarf::Tag)0, dwarf::DW_CHILDREN_no),
+        Parent(0) {}
+
 public:
-  explicit DIE(unsigned Tag)
+  explicit DIE(dwarf::Tag Tag)
       : Offset(0), Size(0), Abbrev((dwarf::Tag)Tag, dwarf::DW_CHILDREN_no),
         Parent(0) {}
   ~DIE();
@@ -464,7 +469,7 @@ public:
 class DIELoc : public DIEValue, public DIE {
   mutable unsigned Size; // Size in bytes excluding size header.
 public:
-  DIELoc() : DIEValue(isLoc), DIE(0), Size(0) {}
+  DIELoc() : DIEValue(isLoc), Size(0) {}
 
   /// ComputeSize - Calculate the size of the location expression.
   ///
@@ -507,7 +512,7 @@ public:
 class DIEBlock : public DIEValue, public DIE {
   mutable unsigned Size; // Size in bytes excluding size header.
 public:
-  DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {}
+  DIEBlock() : DIEValue(isBlock), Size(0) {}
 
   /// ComputeSize - Calculate the size of the location expression.
   ///

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=206098&r1=206097&r2=206098&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Apr 11 21:24:04 2014
@@ -791,8 +791,7 @@ void DwarfDebug::constructImportedEntity
   assert(Module.Verify() &&
          "Use one of the MDNode * overloads to handle invalid metadata");
   assert(Context && "Should always have a context for an imported_module");
-  DIE *IMDie = new DIE(Module.getTag());
-  TheCU->insertDIE(Module, IMDie);
+  DIE *IMDie = TheCU->createAndAddDIE(Module.getTag(), *Context, Module);
   DIE *EntityDie;
   DIDescriptor Entity = resolve(Module.getEntity());
   if (Entity.isNameSpace())
@@ -810,7 +809,6 @@ void DwarfDebug::constructImportedEntity
   StringRef Name = Module.getName();
   if (!Name.empty())
     TheCU->addString(IMDie, dwarf::DW_AT_name, Name);
-  Context->addChild(IMDie);
 }
 
 // Emit all Dwarf sections that should come prior to the content. Create

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=206098&r1=206097&r2=206098&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Apr 11 21:24:04 2014
@@ -90,7 +90,7 @@ public:
   int getFrameIndex() const { return FrameIndex; }
   void setFrameIndex(int FI) { FrameIndex = FI; }
   // Translate tag to proper Dwarf tag.
-  uint16_t getTag() const {
+  dwarf::Tag getTag() const {
     if (Var.getTag() == dwarf::DW_TAG_arg_variable)
       return dwarf::DW_TAG_formal_parameter;
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=206098&r1=206097&r2=206098&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Apr 11 21:24:04 2014
@@ -384,7 +384,9 @@ void DwarfUnit::addDIEEntry(DIE *Die, dw
 /// Create a DIE with the given Tag, add the DIE to its parent, and
 /// call insertDIE if MD is not null.
 DIE *DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, DIDescriptor N) {
-  DIE *Die = new DIE(Tag);
+  assert(Tag != dwarf::DW_TAG_auto_variable &&
+         Tag != dwarf::DW_TAG_arg_variable);
+  DIE *Die = new DIE((dwarf::Tag)Tag);
   Parent.addChild(Die);
   if (N)
     insertDIE(N, Die);





More information about the llvm-commits mailing list