patch-r261991-llvm-r198389-fix-dwarf2.diff revision 269012
1Pull in r198389 from upstream llvm trunk (by David Blaikie):
2
3  Revert "Reverting r193835 due to weirdness with Go..."
4
5  The cgo problem was that it wants dwarf2 which doesn't support direct
6  constant encoding of the location. So let's add support for dwarf2
7  encoding (using a location expression) of data member locations.
8
9  This reverts commit r198385.
10
11Introduced here: http://svnweb.freebsd.org/changeset/base/261991
12
13Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
14===================================================================
15--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
16+++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
17@@ -1890,10 +1890,14 @@ void CompileUnit::constructMemberDIE(DIE &Buffer,
18       // This is not a bitfield.
19       OffsetInBytes = DT.getOffsetInBits() >> 3;
20 
21-    DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
22-    addUInt(MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
23-    addUInt(MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
24-    addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
25+    if (DD->getDwarfVersion() <= 2) {
26+      DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
27+      addUInt(MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
28+      addUInt(MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
29+      addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
30+    } else
31+      addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
32+              OffsetInBytes);
33   }
34 
35   if (DT.isProtected())
36Index: test/DebugInfo/X86/data_member_location.ll
37===================================================================
38--- test/DebugInfo/X86/data_member_location.ll
39+++ test/DebugInfo/X86/data_member_location.ll
40@@ -1,4 +1,5 @@
41 ; RUN: llc -mtriple=x86_64-linux -O0 -o - -filetype=obj < %s | llvm-dwarfdump -debug-dump=info -| FileCheck %s
42+; RUN: llc -mtriple=x86_64-linux -dwarf-version=2 -O0 -o - -filetype=obj < %s | llvm-dwarfdump -debug-dump=info -| FileCheck -check-prefix=DWARF2 %s
43 
44 ; Generated from Clang with the following source:
45 ;
46@@ -11,12 +12,20 @@
47 
48 ; CHECK: DW_AT_name {{.*}} "c"
49 ; CHECK-NOT: DW_TAG
50-; CHECK: DW_AT_data_member_location {{.*}} (<0x02> 23 00 )
51+; CHECK: DW_AT_data_member_location {{.*}} (0x00)
52 
53 ; CHECK: DW_AT_name {{.*}} "i"
54 ; CHECK-NOT: DW_TAG
55-; CHECK: DW_AT_data_member_location {{.*}} (<0x02> 23 04 )
56+; CHECK: DW_AT_data_member_location {{.*}} (0x04)
57 
58+; DWARF2: DW_AT_name {{.*}} "c"
59+; DWARF2-NOT: DW_TAG
60+; DWARF2: DW_AT_data_member_location {{.*}} (<0x02> 23 00 )
61+
62+; DWARF2: DW_AT_name {{.*}} "i"
63+; DWARF2-NOT: DW_TAG
64+; DWARF2: DW_AT_data_member_location {{.*}} (<0x02> 23 04 )
65+
66 %struct.foo = type { i8, i32 }
67 
68 @f = global %struct.foo zeroinitializer, align 4
69Index: test/DebugInfo/X86/concrete_out_of_line.ll
70===================================================================
71--- test/DebugInfo/X86/concrete_out_of_line.ll
72+++ test/DebugInfo/X86/concrete_out_of_line.ll
73@@ -7,7 +7,7 @@
74 ; first check that we have a TAG_subprogram at a given offset and it has
75 ; AT_inline.
76 
77-; CHECK: 0x0000011e:   DW_TAG_subprogram [17]
78+; CHECK: 0x0000011c:   DW_TAG_subprogram [17]
79 ; CHECK-NEXT:     DW_AT_specification
80 ; CHECK-NEXT:     DW_AT_inline
81 
82@@ -14,8 +14,8 @@
83 
84 ; and then that a TAG_subprogram refers to it with AT_abstract_origin.
85 
86-; CHECK: 0x0000015f:   DW_TAG_subprogram [19]
87-; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x011e => {0x0000011e})
88+; CHECK: 0x0000015d:   DW_TAG_subprogram [19]
89+; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x011c => {0x0000011c})
90 
91 define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {
92 entry:
93Index: test/DebugInfo/X86/generate-odr-hash.ll
94===================================================================
95--- test/DebugInfo/X86/generate-odr-hash.ll
96+++ test/DebugInfo/X86/generate-odr-hash.ll
97@@ -1,8 +1,5 @@
98 ; REQUIRES: object-emission
99 
100-; Fail while investigating problem with non-block representations of member offsets.
101-; XFAIL: *
102-
103 ; RUN: llc %s -o %t -filetype=obj -O0 -generate-odr-hash -mtriple=x86_64-unknown-linux-gnu
104 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
105 ;
106