summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/patches/patch-r261991-llvm-r198389-fix-dwarf2.diff
blob: 3b0d21fdf9a6ee0f46c737f077817feefac5fc10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Pull in r198389 from upstream llvm trunk (by David Blaikie):

  Revert "Reverting r193835 due to weirdness with Go..."

  The cgo problem was that it wants dwarf2 which doesn't support direct
  constant encoding of the location. So let's add support for dwarf2
  encoding (using a location expression) of data member locations.

  This reverts commit r198385.

Introduced here: http://svnweb.freebsd.org/changeset/base/261991

Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1890,10 +1890,14 @@ void CompileUnit::constructMemberDIE(DIE &Buffer,
       // This is not a bitfield.
       OffsetInBytes = DT.getOffsetInBits() >> 3;
 
-    DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
-    addUInt(MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
-    addUInt(MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
-    addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
+    if (DD->getDwarfVersion() <= 2) {
+      DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
+      addUInt(MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
+      addUInt(MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
+      addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
+    } else
+      addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
+              OffsetInBytes);
   }
 
   if (DT.isProtected())
Index: test/DebugInfo/X86/data_member_location.ll
===================================================================
--- test/DebugInfo/X86/data_member_location.ll
+++ test/DebugInfo/X86/data_member_location.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=x86_64-linux -O0 -o - -filetype=obj < %s | llvm-dwarfdump -debug-dump=info -| FileCheck %s
+; RUN: llc -mtriple=x86_64-linux -dwarf-version=2 -O0 -o - -filetype=obj < %s | llvm-dwarfdump -debug-dump=info -| FileCheck -check-prefix=DWARF2 %s
 
 ; Generated from Clang with the following source:
 ;
@@ -11,12 +12,20 @@
 
 ; CHECK: DW_AT_name {{.*}} "c"
 ; CHECK-NOT: DW_TAG
-; CHECK: DW_AT_data_member_location {{.*}} (<0x02> 23 00 )
+; CHECK: DW_AT_data_member_location {{.*}} (0x00)
 
 ; CHECK: DW_AT_name {{.*}} "i"
 ; CHECK-NOT: DW_TAG
-; CHECK: DW_AT_data_member_location {{.*}} (<0x02> 23 04 )
+; CHECK: DW_AT_data_member_location {{.*}} (0x04)
 
+; DWARF2: DW_AT_name {{.*}} "c"
+; DWARF2-NOT: DW_TAG
+; DWARF2: DW_AT_data_member_location {{.*}} (<0x02> 23 00 )
+
+; DWARF2: DW_AT_name {{.*}} "i"
+; DWARF2-NOT: DW_TAG
+; DWARF2: DW_AT_data_member_location {{.*}} (<0x02> 23 04 )
+
 %struct.foo = type { i8, i32 }
 
 @f = global %struct.foo zeroinitializer, align 4
Index: test/DebugInfo/X86/concrete_out_of_line.ll
===================================================================
--- test/DebugInfo/X86/concrete_out_of_line.ll
+++ test/DebugInfo/X86/concrete_out_of_line.ll
@@ -7,7 +7,7 @@
 ; first check that we have a TAG_subprogram at a given offset and it has
 ; AT_inline.
 
-; CHECK: 0x0000011e:   DW_TAG_subprogram [17]
+; CHECK: 0x0000011c:   DW_TAG_subprogram [17]
 ; CHECK-NEXT:     DW_AT_specification
 ; CHECK-NEXT:     DW_AT_inline
 
@@ -14,8 +14,8 @@
 
 ; and then that a TAG_subprogram refers to it with AT_abstract_origin.
 
-; CHECK: 0x0000015f:   DW_TAG_subprogram [19]
-; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x011e => {0x0000011e})
+; CHECK: 0x0000015d:   DW_TAG_subprogram [19]
+; CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]    (cu + 0x011c => {0x0000011c})
 
 define i32 @_ZN17nsAutoRefCnt7ReleaseEv() {
 entry:
Index: test/DebugInfo/X86/generate-odr-hash.ll
===================================================================
--- test/DebugInfo/X86/generate-odr-hash.ll
+++ test/DebugInfo/X86/generate-odr-hash.ll
@@ -1,8 +1,5 @@
 ; REQUIRES: object-emission
 
-; Fail while investigating problem with non-block representations of member offsets.
-; XFAIL: *
-
 ; RUN: llc %s -o %t -filetype=obj -O0 -generate-odr-hash -mtriple=x86_64-unknown-linux-gnu
 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
 ;
OpenPOWER on IntegriCloud