blob: ca8525cd335bd3a5a6d04ff6e558357f68ed6e69 [file] [log] [blame]
David Blaikie488393f2017-05-12 01:13:45 +00001; RUN: llc -mtriple=x86_64-linux -split-dwarf-cross-cu-references -split-dwarf-file=foo.dwo -filetype=obj -o %t < %s
2; RUN: llvm-objdump -r %t | FileCheck %s
3; RUN: llvm-dwarfdump -debug-dump=info.dwo %t | FileCheck --check-prefix=ALL --check-prefix=INFO --check-prefix=DWO --check-prefix=CROSS %s
4; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck --check-prefix=ALL --check-prefix=INFO %s
5
6; RUN: llc -mtriple=x86_64-linux -split-dwarf-file=foo.dwo -filetype=obj -o %t < %s
7; RUN: llvm-objdump -r %t | FileCheck %s
8; RUN: llvm-dwarfdump -debug-dump=info.dwo %t | FileCheck --check-prefix=ALL --check-prefix=DWO --check-prefix=NOCROSS %s
9; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck --check-prefix=ALL --check-prefix=INFO %s
10
11; Testing cross-CU references for types, subprograms, and variables
12; Built from code something like this:
13; foo.cpp:
14; struct t1 { int i; };
15; void f();
16; __attribute__((always_inline)) void f1(t1 t) {
17; f();
18; }
19; void foo(t1 t) {
20; f1(t);
21; }
22; bar.cpp:
23; struct t1 { int i; };
24; void f1(t1);
25; void bar(t1 t) {
26; f1(t);
27; }
28; $ clang++-tot -emit-llvm -S {foo,bar}.cpp -g
29; $ llvm-link-tot {foo,bar}.ll -S -o foobar.ll
30; $ clang++-tot -emit-llvm foobar.ll -o foobar.opt.ll -S -c
31;
32; Then manually removing the original f1 definition, to simplify the DWARF a bit
33; (so it only has the inlined definitions, no concrete definition)
34
35; Check that:
36; * no relocations are emitted for the debug_info.dwo section no matter what
37; * one debug_info->debug_info relocation in debug_info no matter what (for
38; split dwarf inlining)
39; * debug_info uses relocations and ref_addr no matter what
40; * debug_info.dwo uses relocations for types as well as abstract subprograms
41; and variables when -split-dwarf-cross-cu-references is used
42; * debug_info.dwo contains duplicate types, abstract subprograms and abstract
43; variables otherwise to avoid the need for cross-cu references
David Blaikie85366ac2017-04-22 07:53:44 +000044
David Blaikie5477b972017-04-22 08:17:39 +000045; CHECK-NOT: .rel{{a?}}.debug_info.dwo
46; CHECK: RELOCATION RECORDS FOR [.rel{{a?}}.debug_info]:
David Blaikie85366ac2017-04-22 07:53:44 +000047; CHECK-NOT: RELOCATION RECORDS
David Blaikie488393f2017-05-12 01:13:45 +000048; Expect one relocation in debug_info, from the inlined f1 in foo to its
49; abstract origin in bar
David Blaikie85366ac2017-04-22 07:53:44 +000050; CHECK: R_X86_64_32 .debug_info
David Blaikie488393f2017-05-12 01:13:45 +000051; CHECK-NOT: RELOCATION RECORDS
David Blaikie85366ac2017-04-22 07:53:44 +000052; CHECK-NOT: .debug_info
53; CHECK: RELOCATION RECORDS
David Blaikie5477b972017-04-22 08:17:39 +000054; CHECK-NOT: .rel{{a?}}.debug_info.dwo
David Blaikie85366ac2017-04-22 07:53:44 +000055
David Blaikie488393f2017-05-12 01:13:45 +000056; ALL: Compile Unit
57; ALL: DW_TAG_compile_unit
58; DWO: DW_AT_name {{.*}} "foo.cpp"
59; ALL: 0x[[F1:.*]]: DW_TAG_subprogram
60; ALL: DW_AT_name {{.*}} "f1"
61; DWO: 0x[[F1T:.*]]: DW_TAG_formal_parameter
62; DWO: DW_AT_name {{.*}} "t"
63; DWO: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[T1:.*]]}
64; DWO: NULL
65; DWO: 0x[[T1]]: DW_TAG_structure_type
66; DWO: DW_AT_name {{.*}} "t1"
67; ALL: DW_TAG_subprogram
68; ALL: DW_AT_name {{.*}} "foo"
69; DWO: DW_TAG_formal_parameter
70; DWO: DW_AT_name {{.*}} "t"
71; DWO: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[T1]]}
72; ALL: DW_TAG_inlined_subroutine
73; ALL: DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[F1]]}
74; DWO: DW_TAG_formal_parameter
75; DWO: DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[F1T]]}
David Blaikie85366ac2017-04-22 07:53:44 +000076
David Blaikie488393f2017-05-12 01:13:45 +000077; ALL: Compile Unit
78; ALL: DW_TAG_compile_unit
79; DWO: DW_AT_name {{.*}} "bar.cpp"
80; NOCROSS: 0x[[BAR_F1:.*]]: DW_TAG_subprogram
81; NOCROSS: DW_AT_name {{.*}} "f1"
82; NOCROSS: 0x[[BAR_F1T:.*]]: DW_TAG_formal_parameter
83; NOCROSS: DW_AT_name {{.*}} "t"
84; NOCROSS: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[BAR_T1:.*]]}
85; NOCROSS: NULL
86; NOCROSS: 0x[[BAR_T1]]: DW_TAG_structure_type
87; NOCROSS: DW_AT_name {{.*}} "t1"
88; ALL: DW_TAG_subprogram
89; ALL: DW_AT_name {{.*}} "bar"
90; DWO: DW_TAG_formal_parameter
91; DWO: DW_AT_name {{.*}} "t"
92; CROSS: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[T1]]
93; NOCROSS: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[BAR_T1]]}
94; ALL: DW_TAG_inlined_subroutine
95; INFO: DW_AT_abstract_origin [DW_FORM_ref_addr] (0x00000000[[F1]]
96; NOCROSS: DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[BAR_F1]]}
97; DWO: DW_TAG_formal_parameter
98; CROSS: DW_AT_abstract_origin [DW_FORM_ref_addr] (0x00000000[[F1T]]
99; NOCROSS: DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[BAR_F1T]]
100
101%struct.t1 = type { i32 }
102
103; Function Attrs: nounwind readnone speculatable
104declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
105
106declare void @_Z1fv() #2
David Blaikie85366ac2017-04-22 07:53:44 +0000107
108; Function Attrs: noinline uwtable
David Blaikie488393f2017-05-12 01:13:45 +0000109define void @_Z3foo2t1(i32 %t.coerce) #3 !dbg !20 {
David Blaikie85366ac2017-04-22 07:53:44 +0000110entry:
David Blaikie488393f2017-05-12 01:13:45 +0000111 %t.i = alloca %struct.t1, align 4
112 call void @llvm.dbg.declare(metadata %struct.t1* %t.i, metadata !15, metadata !16), !dbg !21
113 %t = alloca %struct.t1, align 4
114 %agg.tmp = alloca %struct.t1, align 4
115 %coerce.dive = getelementptr inbounds %struct.t1, %struct.t1* %t, i32 0, i32 0
116 store i32 %t.coerce, i32* %coerce.dive, align 4
117 call void @llvm.dbg.declare(metadata %struct.t1* %t, metadata !23, metadata !16), !dbg !24
118 %0 = bitcast %struct.t1* %agg.tmp to i8*, !dbg !25
119 %1 = bitcast %struct.t1* %t to i8*, !dbg !25
120 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* %1, i64 4, i32 4, i1 false), !dbg !25
121 %coerce.dive1 = getelementptr inbounds %struct.t1, %struct.t1* %agg.tmp, i32 0, i32 0, !dbg !26
122 %2 = load i32, i32* %coerce.dive1, align 4, !dbg !26
123 %coerce.dive.i = getelementptr inbounds %struct.t1, %struct.t1* %t.i, i32 0, i32 0
124 store i32 %2, i32* %coerce.dive.i, align 4
125 call void @_Z1fv(), !dbg !27
126 ret void, !dbg !28
127}
128
129; Function Attrs: argmemonly nounwind
130declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #4
131
132; Function Attrs: noinline uwtable
133define void @_Z3bar2t1(i32 %t.coerce) #3 !dbg !29 {
134entry:
135 %t.i = alloca %struct.t1, align 4
136 call void @llvm.dbg.declare(metadata %struct.t1* %t.i, metadata !15, metadata !16), !dbg !30
137 %t = alloca %struct.t1, align 4
138 %agg.tmp = alloca %struct.t1, align 4
139 %coerce.dive = getelementptr inbounds %struct.t1, %struct.t1* %t, i32 0, i32 0
140 store i32 %t.coerce, i32* %coerce.dive, align 4
141 call void @llvm.dbg.declare(metadata %struct.t1* %t, metadata !32, metadata !16), !dbg !33
142 %0 = bitcast %struct.t1* %agg.tmp to i8*, !dbg !34
143 %1 = bitcast %struct.t1* %t to i8*, !dbg !34
144 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* %1, i64 4, i32 4, i1 false), !dbg !34
145 %coerce.dive1 = getelementptr inbounds %struct.t1, %struct.t1* %agg.tmp, i32 0, i32 0, !dbg !35
146 %2 = load i32, i32* %coerce.dive1, align 4, !dbg !35
147 %coerce.dive.i = getelementptr inbounds %struct.t1, %struct.t1* %t.i, i32 0, i32 0
148 store i32 %2, i32* %coerce.dive.i, align 4
149 call void @_Z1fv(), !dbg !36
150 ret void, !dbg !37
David Blaikie85366ac2017-04-22 07:53:44 +0000151}
152
153!llvm.dbg.cu = !{!0, !3}
154!llvm.ident = !{!5, !5}
David Blaikie488393f2017-05-12 01:13:45 +0000155!llvm.module.flags = !{!6, !7}
David Blaikie85366ac2017-04-22 07:53:44 +0000156
David Blaikie488393f2017-05-12 01:13:45 +0000157!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 302809) (llvm/trunk 302815)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: true)
158!1 = !DIFile(filename: "foo.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
David Blaikie85366ac2017-04-22 07:53:44 +0000159!2 = !{}
David Blaikie488393f2017-05-12 01:13:45 +0000160!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 5.0.0 (trunk 302809) (llvm/trunk 302815)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: true)
161!4 = !DIFile(filename: "bar.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
162!5 = !{!"clang version 5.0.0 (trunk 302809) (llvm/trunk 302815)"}
163!6 = !{i32 2, !"Dwarf Version", i32 4}
164!7 = !{i32 2, !"Debug Info Version", i32 3}
165!8 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f12t1", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
166!9 = !DISubroutineType(types: !10)
167!10 = !{null, !11}
168!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !1, line: 1, size: 32, elements: !12, identifier: "_ZTS2t1")
169!12 = !{!13}
170!13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !11, file: !1, line: 1, baseType: !14, size: 32)
171!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
172!15 = !DILocalVariable(name: "t", arg: 1, scope: !8, file: !1, line: 3, type: !11)
173!16 = !DIExpression()
174!17 = !DILocation(line: 3, column: 43, scope: !8)
175!18 = !DILocation(line: 4, column: 3, scope: !8)
176!19 = !DILocation(line: 5, column: 1, scope: !8)
177!20 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo2t1", scope: !1, file: !1, line: 6, type: !9, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
178!21 = !DILocation(line: 3, column: 43, scope: !8, inlinedAt: !22)
179!22 = distinct !DILocation(line: 7, column: 3, scope: !20)
180!23 = !DILocalVariable(name: "t", arg: 1, scope: !20, file: !1, line: 6, type: !11)
181!24 = !DILocation(line: 6, column: 13, scope: !20)
182!25 = !DILocation(line: 7, column: 6, scope: !20)
183!26 = !DILocation(line: 7, column: 3, scope: !20)
184!27 = !DILocation(line: 4, column: 3, scope: !8, inlinedAt: !22)
185!28 = !DILocation(line: 8, column: 1, scope: !20)
186!29 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bar2t1", scope: !4, file: !4, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !3, variables: !2)
187!30 = !DILocation(line: 3, column: 43, scope: !8, inlinedAt: !31)
188!31 = distinct !DILocation(line: 4, column: 3, scope: !29)
189!32 = !DILocalVariable(name: "t", arg: 1, scope: !29, file: !4, line: 3, type: !11)
190!33 = !DILocation(line: 3, column: 13, scope: !29)
191!34 = !DILocation(line: 4, column: 6, scope: !29)
192!35 = !DILocation(line: 4, column: 3, scope: !29)
193!36 = !DILocation(line: 4, column: 3, scope: !8, inlinedAt: !31)
194!37 = !DILocation(line: 5, column: 1, scope: !29)