[PATCH] D87016: [DebugInfo] Fix emitting the DW_AT_location attribute for 64-bit DWARFv3 (7/19).

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 22:24:59 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG26f1f1883134: [DebugInfo] Fix emitting the DW_AT_location attribute for 64-bit DWARFv3 (7/19). (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87016

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/test/DebugInfo/X86/DW_AT_location-reference.ll


Index: llvm/test/DebugInfo/X86/DW_AT_location-reference.ll
===================================================================
--- llvm/test/DebugInfo/X86/DW_AT_location-reference.ll
+++ llvm/test/DebugInfo/X86/DW_AT_location-reference.ll
@@ -1,8 +1,17 @@
 ; RUN: llc -O1 -filetype=obj -mtriple=x86_64-apple-darwin < %s > %t
-; RUN: llvm-dwarfdump -v %t  | FileCheck %s
+; RUN: llvm-dwarfdump -v %t | FileCheck %s --check-prefixes=CHECK,DWARFv4
 ; RUN: llvm-objdump -r %t | FileCheck --check-prefix=DARWIN %s
+
 ; RUN: llc -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t
-; RUN: llvm-dwarfdump -v %t  | FileCheck %s
+; RUN: llvm-dwarfdump -v %t | FileCheck %s --check-prefixes=CHECK,DWARFv4
+; RUN: llvm-objdump -r %t | FileCheck --check-prefix=LINUX %s
+
+; RUN: llc -dwarf-version=3 -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t
+; RUN: llvm-dwarfdump -debug-info -v %t | FileCheck %s --check-prefixes=CHECK,DWARF32v3
+; RUN: llvm-objdump -r %t | FileCheck --check-prefix=LINUX %s
+
+; RUN: llc -dwarf64 -dwarf-version=3 -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t
+; RUN: llvm-dwarfdump -debug-info -v %t | FileCheck %s --check-prefixes=CHECK,DWARF64v3
 ; RUN: llvm-objdump -r %t | FileCheck --check-prefix=LINUX %s
 
 ; PR9493
@@ -31,7 +40,9 @@
 ; // The 'x' variable and its symbol reference location
 ; CHECK: .debug_info contents:
 ; CHECK:      DW_TAG_variable
-; CHECK-NEXT:   DW_AT_location [DW_FORM_sec_offset] (0x00000000
+; DWARF32v3-NEXT: DW_AT_location [DW_FORM_data4] (0x00000000
+; DWARF64v3-NEXT: DW_AT_location [DW_FORM_data8] (0x00000000
+; DWARFv4-NEXT:   DW_AT_location [DW_FORM_sec_offset] (0x00000000
 ; Check that the location contains only 4 ranges.
 ; CHECK-NEXT:   [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}})
 ; CHECK-NEXT:   [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}})
Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1346,11 +1346,9 @@
 /// Add a Dwarf loclistptr attribute data and value.
 void DwarfCompileUnit::addLocationList(DIE &Die, dwarf::Attribute Attribute,
                                        unsigned Index) {
-  dwarf::Form Form = dwarf::DW_FORM_data4;
-  if (DD->getDwarfVersion() == 4)
-    Form =dwarf::DW_FORM_sec_offset;
-  if (DD->getDwarfVersion() >= 5)
-    Form =dwarf::DW_FORM_loclistx;
+  dwarf::Form Form = (DD->getDwarfVersion() >= 5)
+                         ? dwarf::DW_FORM_loclistx
+                         : DD->getDwarfSectionOffsetForm();
   Die.addValue(DIEValueAllocator, Attribute, Form, DIELocList(Index));
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87016.291786.patch
Type: text/x-patch
Size: 2685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200915/536fe48f/attachment.bin>


More information about the llvm-commits mailing list