[llvm] r178722 - Debug Info: according to DWARF 2, FORM_ref_addr the same size as an address on

Manman Ren mren at apple.com
Wed Apr 3 17:22:54 PDT 2013


Author: mren
Date: Wed Apr  3 19:22:54 2013
New Revision: 178722

URL: http://llvm.org/viewvc/llvm-project?rev=178722&view=rev
Log:
Debug Info: according to DWARF 2, FORM_ref_addr the same size as an address on
the target system.

It was hard-coded to 4 bytes before. I can't get llvm to generate a
ref_addr on a reasonably sized testing case.

rdar://problem/13559431

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

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=178722&r1=178721&r2=178722&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Wed Apr  3 19:22:54 2013
@@ -310,6 +310,12 @@ void DIEEntry::EmitValue(AsmPrinter *AP,
   AP->EmitInt32(Entry->getOffset());
 }
 
+unsigned DIEEntry::SizeOf(AsmPrinter *AP, unsigned Form) const {
+  if (Form == dwarf::DW_FORM_ref_addr)
+    return AP->getDataLayout().getPointerSize();
+  return sizeof(int32_t);
+}
+
 #ifndef NDEBUG
 void DIEEntry::print(raw_ostream &O) {
   O << format("Die: 0x%lx", (long)(intptr_t)Entry);

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=178722&r1=178721&r2=178722&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Wed Apr  3 19:22:54 2013
@@ -336,9 +336,7 @@ namespace llvm {
 
     /// SizeOf - Determine size of debug information entry in bytes.
     ///
-    virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const {
-      return sizeof(int32_t);
-    }
+    virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const;
 
     // Implement isa/cast/dyncast.
     static bool classof(const DIEValue *E) { return E->getType() == isEntry; }

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=178722&r1=178721&r2=178722&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr  3 19:22:54 2013
@@ -1791,7 +1791,14 @@ void DwarfDebug::emitDIE(DIE *Die, std::
         DwarfUnits &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
         Addr += Holder.getCUOffset(Origin->getCompileUnit());
       }
-      Asm->EmitInt32(Addr);
+      // DWARF4: References that use the attribute form DW_FORM_ref_addr are
+      // specified to be four bytes in the DWARF 32-bit format and eight bytes
+      // in the DWARF 64-bit format, while DWARF Version 2 specifies that such
+      // references have the same size as an address on the target system.
+      // Our current version is version 2.
+      Asm->OutStreamer.EmitIntValue(Addr,
+          Form == dwarf::DW_FORM_ref_addr ?
+          Asm->getDataLayout().getPointerSize() : 4);
       break;
     }
     case dwarf::DW_AT_ranges: {





More information about the llvm-commits mailing list