[PATCH] D83958: [DebugInfo] Fix a misleading usage of DWARF forms with DIEExpr. NFC.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 23:50:37 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf76a0cd97aa2: [DebugInfo] Fix a misleading usage of DWARF forms with DIEExpr. NFCI. (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83958/new/

https://reviews.llvm.org/D83958

Files:
  llvm/lib/CodeGen/AsmPrinter/DIE.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp


Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -260,7 +260,9 @@
                                      : dwarf::DW_OP_const8u);
             // 2) containing the (relocated) offset of the TLS variable
             //    within the module's TLS block.
-            addExpr(*Loc, dwarf::DW_FORM_udata,
+            addExpr(*Loc,
+                    PointerSize == 4 ? dwarf::DW_FORM_data4
+                                     : dwarf::DW_FORM_data8,
                     Asm->getObjFileLowering().getDebugThreadLocalSymbol(Sym));
           } else {
             addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -472,10 +472,17 @@
 /// SizeOf - Determine size of expression value in bytes.
 ///
 unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
-  if (Form == dwarf::DW_FORM_data4) return 4;
-  if (Form == dwarf::DW_FORM_sec_offset) return 4;
-  if (Form == dwarf::DW_FORM_strp) return 4;
-  return AP->getPointerSize();
+  switch (Form) {
+  case dwarf::DW_FORM_data4:
+    return 4;
+  case dwarf::DW_FORM_data8:
+    return 8;
+  case dwarf::DW_FORM_sec_offset:
+    // FIXME: add support for DWARF64
+    return 4;
+  default:
+    llvm_unreachable("DIE Value form not supported yet");
+  }
 }
 
 LLVM_DUMP_METHOD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83958.278666.patch
Type: text/x-patch
Size: 1640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200717/03b3108d/attachment.bin>


More information about the llvm-commits mailing list