xref: /llvm-project/llvm/test/DebugInfo/AArch64/frameindices.ll (revision 3a05e01d1a76984fe1532bd237edbbb7ed9db6ea)
1; RUN: llc -frame-pointer=all -O0 -fast-isel -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
2; RUN: llc --try-experimental-debuginfo-iterators -frame-pointer=all -O0 -fast-isel -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s
3; Test that a variable with multiple entries in the MMI table makes it into the
4; debug info.
5;
6; CHECK: DW_TAG_inlined_subroutine
7; CHECK:    "_Z3f111A"
8; CHECK: DW_TAG_formal_parameter
9; CHECK: DW_AT_location [DW_FORM_block1]    (DW_OP_piece 0x1, DW_OP_fbreg -47, DW_OP_piece 0xf, DW_OP_piece 0x1, DW_OP_breg31 WSP+42, DW_OP_piece 0x7)
10; CHECK: DW_AT_abstract_origin {{.*}} "p1"
11;
12; long a;
13; struct A {
14;   bool x4;
15;   void *x5;
16;   bool x6;
17; };
18; int *b;
19; struct B {
20;   B(long);
21;   ~B();
22; };
23; void f9(A);
24; void f13(A p1) {
25;   b = (int *)__builtin_operator_new(a);
26;   f9(p1);
27; }
28; void f11(A p1) { f13(p1); }
29; void f16() {
30;   A c;
31;   B d(a);
32;   c.x6 = c.x4 = true;
33;   f11(c);
34; }
35; ModuleID = 'test.cpp'
36source_filename = "test/DebugInfo/AArch64/frameindices.ll"
37target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
38target triple = "aarch64-apple-ios"
39
40%struct.A = type { i8, ptr, i8 }
41%struct.B = type { i8 }
42
43@a = global i64 0, align 8, !dbg !0
44@b = global ptr null, align 8, !dbg !4
45
46define void @_Z3f131A(ptr nocapture readonly %p1) !dbg !32 {
47entry:
48  %agg.tmp = alloca %struct.A, align 8
49  tail call void @llvm.dbg.declare(metadata ptr %p1, metadata !36, metadata !37), !dbg !38
50  %0 = load i64, ptr @a, align 8, !dbg !39, !tbaa !40
51  %call = tail call noalias ptr @_Znwm(i64 %0) #4, !dbg !44
52  store ptr %call, ptr @b, align 8, !dbg !45, !tbaa !46
53  %1 = getelementptr inbounds %struct.A, ptr %agg.tmp, i64 0, i32 0, !dbg !48
54  %2 = getelementptr inbounds %struct.A, ptr %p1, i64 0, i32 0, !dbg !48
55  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %2, i64 24, i1 false), !dbg !48, !tbaa.struct !49
56  call void @_Z2f91A(ptr %agg.tmp), !dbg !52
57  ret void, !dbg !53
58}
59
60; Function Attrs: nounwind readnone
61declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
62
63; Function Attrs: nobuiltin
64declare noalias ptr @_Znwm(i64) #1
65
66declare void @_Z2f91A(ptr)
67
68; Function Attrs: argmemonly nounwind
69declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #2
70
71define void @_Z3f111A(ptr nocapture readonly %p1) !dbg !54 {
72entry:
73  %agg.tmp.i = alloca %struct.A, align 8
74  tail call void @llvm.dbg.declare(metadata ptr %p1, metadata !56, metadata !37), !dbg !57
75  %0 = getelementptr inbounds %struct.A, ptr %p1, i64 0, i32 0, !dbg !58
76  %1 = getelementptr inbounds %struct.A, ptr %agg.tmp.i, i64 0, i32 0, !dbg !59
77  call void @llvm.lifetime.start(i64 24, ptr %1), !dbg !59
78  %2 = load i64, ptr @a, align 8, !dbg !61, !tbaa !40
79  %call.i = tail call noalias ptr @_Znwm(i64 %2) #4, !dbg !62
80  store ptr %call.i, ptr @b, align 8, !dbg !63, !tbaa !46
81  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 %0, i64 24, i1 false), !dbg !64
82  call void @_Z2f91A(ptr %agg.tmp.i), !dbg !65
83  call void @llvm.lifetime.end(i64 24, ptr %1), !dbg !66
84  ret void, !dbg !67
85}
86
87define void @_Z3f16v() personality ptr @__gxx_personality_v0 !dbg !68 {
88entry:
89  %agg.tmp.i.i = alloca %struct.A, align 8
90  %d = alloca %struct.B, align 8
91  %agg.tmp.sroa.2 = alloca [15 x i8], align 1
92  %agg.tmp.sroa.4 = alloca [7 x i8], align 1
93  tail call void @llvm.dbg.declare(metadata ptr %agg.tmp.sroa.2, metadata !56, metadata !74), !dbg !75
94  tail call void @llvm.dbg.declare(metadata ptr %agg.tmp.sroa.4, metadata !56, metadata !77), !dbg !75
95  tail call void @llvm.dbg.declare(metadata ptr undef, metadata !72, metadata !37), !dbg !78
96  %0 = load i64, ptr @a, align 8, !dbg !79, !tbaa !40
97  tail call void @llvm.dbg.value(metadata ptr %d, metadata !73, metadata !37), !dbg !80
98  %call = call ptr @_ZN1BC1El(ptr %d, i64 %0), !dbg !80
99  call void @llvm.dbg.value(metadata i8 1, metadata !72, metadata !81), !dbg !78
100  call void @llvm.dbg.value(metadata i8 1, metadata !72, metadata !82), !dbg !78
101  call void @llvm.dbg.value(metadata i8 1, metadata !56, metadata !81), !dbg !75
102  call void @llvm.dbg.value(metadata i8 1, metadata !56, metadata !82), !dbg !75
103  call void @llvm.dbg.declare(metadata ptr undef, metadata !56, metadata !37), !dbg !75
104  %1 = getelementptr inbounds %struct.A, ptr %agg.tmp.i.i, i64 0, i32 0, !dbg !83
105  call void @llvm.lifetime.start(i64 24, ptr %1), !dbg !83
106  %2 = load i64, ptr @a, align 8, !dbg !85, !tbaa !40
107  %call.i.i5 = invoke noalias ptr @_Znwm(i64 %2) #4
108          to label %call.i.i.noexc unwind label %lpad, !dbg !86
109
110call.i.i.noexc:                                   ; preds = %entry
111  %agg.tmp.sroa.4.17..sroa_idx = getelementptr inbounds [7 x i8], ptr %agg.tmp.sroa.4, i64 0, i64 0, !dbg !87
112  %agg.tmp.sroa.2.1..sroa_idx = getelementptr inbounds [15 x i8], ptr %agg.tmp.sroa.2, i64 0, i64 0, !dbg !87
113  store ptr %call.i.i5, ptr @b, align 8, !dbg !88, !tbaa !46
114  store i8 1, ptr %1, align 8, !dbg !89
115  %agg.tmp.sroa.2.0..sroa_raw_idx = getelementptr inbounds i8, ptr %1, i64 1, !dbg !89
116  call void @llvm.memcpy.p0.p0.i64(ptr %agg.tmp.sroa.2.0..sroa_raw_idx, ptr %agg.tmp.sroa.2.1..sroa_idx, i64 15, i1 false), !dbg !89
117  %agg.tmp.sroa.3.0..sroa_idx = getelementptr inbounds %struct.A, ptr %agg.tmp.i.i, i64 0, i32 2, !dbg !89
118  store i8 1, ptr %agg.tmp.sroa.3.0..sroa_idx, align 8, !dbg !89
119  %agg.tmp.sroa.4.0..sroa_raw_idx = getelementptr inbounds i8, ptr %1, i64 17, !dbg !89
120  call void @llvm.memcpy.p0.p0.i64(ptr %agg.tmp.sroa.4.0..sroa_raw_idx, ptr %agg.tmp.sroa.4.17..sroa_idx, i64 7, i1 false), !dbg !89
121  invoke void @_Z2f91A(ptr %agg.tmp.i.i)
122          to label %invoke.cont unwind label %lpad, !dbg !90
123
124invoke.cont:                                      ; preds = %call.i.i.noexc
125  call void @llvm.lifetime.end(i64 24, ptr %1), !dbg !91
126  call void @llvm.dbg.value(metadata ptr %d, metadata !73, metadata !37), !dbg !80
127  %call1 = call ptr @_ZN1BD1Ev(ptr %d) #3, !dbg !92
128  ret void, !dbg !92
129
130lpad:                                             ; preds = %call.i.i.noexc, %entry
131  %3 = landingpad { ptr, i32 }
132          cleanup, !dbg !92
133  call void @llvm.dbg.value(metadata ptr %d, metadata !73, metadata !37), !dbg !80
134  %call2 = call ptr @_ZN1BD1Ev(ptr %d) #3, !dbg !92
135  resume { ptr, i32 } %3, !dbg !92
136}
137
138declare ptr @_ZN1BC1El(ptr, i64)
139
140declare i32 @__gxx_personality_v0(...)
141
142; Function Attrs: nounwind
143declare ptr @_ZN1BD1Ev(ptr) #3
144
145; Function Attrs: nounwind readnone
146declare void @llvm.dbg.value(metadata, metadata, metadata) #0
147
148; Function Attrs: argmemonly nounwind
149declare void @llvm.lifetime.start(i64, ptr nocapture) #2
150
151; Function Attrs: argmemonly nounwind
152declare void @llvm.lifetime.end(i64, ptr nocapture) #2
153
154attributes #0 = { nounwind readnone }
155attributes #1 = { nobuiltin }
156attributes #2 = { argmemonly nounwind }
157attributes #3 = { nounwind }
158attributes #4 = { builtin }
159
160!llvm.dbg.cu = !{!8}
161!llvm.module.flags = !{!29, !30}
162!llvm.ident = !{!31}
163
164!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
165!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
166!2 = !DIFile(filename: "test.cpp", directory: "")
167!3 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
168!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
169!5 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 7, type: !6, isLocal: false, isDefinition: true)
170!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
171!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
172!8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !9, producer: "clang version 3.7.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !10, retainedTypes: !11, globals: !28, imports: !10)
173!9 = !DIFile(filename: "<stdin>", directory: "")
174!10 = !{}
175!11 = !{!12, !6, !19}
176!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !2, line: 2, size: 192, align: 64, elements: !13, identifier: "_ZTS1A")
177!13 = !{!14, !16, !18}
178!14 = !DIDerivedType(tag: DW_TAG_member, name: "x4", scope: !12, file: !2, line: 3, baseType: !15, size: 8, align: 8)
179!15 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
180!16 = !DIDerivedType(tag: DW_TAG_member, name: "x5", scope: !12, file: !2, line: 4, baseType: !17, size: 64, align: 64, offset: 64)
181!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64, align: 64)
182!18 = !DIDerivedType(tag: DW_TAG_member, name: "x6", scope: !12, file: !2, line: 5, baseType: !15, size: 8, align: 8, offset: 128)
183!19 = !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !2, line: 8, size: 8, align: 8, elements: !20, identifier: "_ZTS1B")
184!20 = !{!21, !25}
185!21 = !DISubprogram(name: "B", scope: !19, file: !2, line: 9, type: !22, isLocal: false, isDefinition: false, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true)
186!22 = !DISubroutineType(types: !23)
187!23 = !{null, !24, !3}
188!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
189!25 = !DISubprogram(name: "~B", scope: !19, file: !2, line: 10, type: !26, isLocal: false, isDefinition: false, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: true)
190!26 = !DISubroutineType(types: !27)
191!27 = !{null, !24}
192!28 = !{!0, !4}
193!29 = !{i32 2, !"Dwarf Version", i32 2}
194!30 = !{i32 2, !"Debug Info Version", i32 3}
195!31 = !{!"clang version 3.7.0 "}
196!32 = distinct !DISubprogram(name: "f13", linkageName: "_Z3f131A", scope: !2, file: !2, line: 13, type: !33, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, unit: !8, retainedNodes: !35)
197!33 = !DISubroutineType(types: !34)
198!34 = !{null, !12}
199!35 = !{!36}
200!36 = !DILocalVariable(name: "p1", arg: 1, scope: !32, file: !2, line: 13, type: !12)
201!37 = !DIExpression(DW_OP_deref)
202!38 = !DILocation(line: 13, column: 12, scope: !32)
203!39 = !DILocation(line: 14, column: 37, scope: !32)
204!40 = !{!41, !41, i64 0}
205!41 = !{!"long", !42, i64 0}
206!42 = !{!"omnipotent char", !43, i64 0}
207!43 = !{!"Simple C/C++ TBAA"}
208!44 = !DILocation(line: 14, column: 14, scope: !32)
209!45 = !DILocation(line: 14, column: 5, scope: !32)
210!46 = !{!47, !47, i64 0}
211!47 = !{!"any pointer", !42, i64 0}
212!48 = !DILocation(line: 15, column: 6, scope: !32)
213!49 = !{i64 0, i64 1, !50, i64 8, i64 8, !46, i64 16, i64 1, !50}
214!50 = !{!51, !51, i64 0}
215!51 = !{!"bool", !42, i64 0}
216!52 = !DILocation(line: 15, column: 3, scope: !32)
217!53 = !DILocation(line: 16, column: 1, scope: !32)
218!54 = distinct !DISubprogram(name: "f11", linkageName: "_Z3f111A", scope: !2, file: !2, line: 17, type: !33, isLocal: false, isDefinition: true, scopeLine: 17, flags: DIFlagPrototyped, isOptimized: true, unit: !8, retainedNodes: !55)
219!55 = !{!56}
220!56 = !DILocalVariable(name: "p1", arg: 1, scope: !54, file: !2, line: 17, type: !12)
221!57 = !DILocation(line: 17, column: 12, scope: !54)
222!58 = !DILocation(line: 17, column: 22, scope: !54)
223!59 = !DILocation(line: 13, column: 12, scope: !32, inlinedAt: !60)
224!60 = distinct !DILocation(line: 17, column: 18, scope: !54)
225!61 = !DILocation(line: 14, column: 37, scope: !32, inlinedAt: !60)
226!62 = !DILocation(line: 14, column: 14, scope: !32, inlinedAt: !60)
227!63 = !DILocation(line: 14, column: 5, scope: !32, inlinedAt: !60)
228!64 = !DILocation(line: 15, column: 6, scope: !32, inlinedAt: !60)
229!65 = !DILocation(line: 15, column: 3, scope: !32, inlinedAt: !60)
230!66 = !DILocation(line: 16, column: 1, scope: !32, inlinedAt: !60)
231!67 = !DILocation(line: 17, column: 27, scope: !54)
232!68 = distinct !DISubprogram(name: "f16", linkageName: "_Z3f16v", scope: !2, file: !2, line: 18, type: !69, isLocal: false, isDefinition: true, scopeLine: 18, flags: DIFlagPrototyped, isOptimized: true, unit: !8, retainedNodes: !71)
233!69 = !DISubroutineType(types: !70)
234!70 = !{null}
235!71 = !{!72, !73}
236!72 = !DILocalVariable(name: "c", scope: !68, file: !2, line: 19, type: !12)
237!73 = !DILocalVariable(name: "d", scope: !68, file: !2, line: 20, type: !19)
238!74 = !DIExpression(DW_OP_LLVM_fragment, 8, 120)
239!75 = !DILocation(line: 17, column: 12, scope: !54, inlinedAt: !76)
240!76 = distinct !DILocation(line: 22, column: 3, scope: !68)
241!77 = !DIExpression(DW_OP_LLVM_fragment, 136, 56)
242!78 = !DILocation(line: 19, column: 5, scope: !68)
243!79 = !DILocation(line: 20, column: 7, scope: !68)
244!80 = !DILocation(line: 20, column: 5, scope: !68)
245!81 = !DIExpression(DW_OP_LLVM_fragment, 0, 8)
246!82 = !DIExpression(DW_OP_LLVM_fragment, 128, 8)
247!83 = !DILocation(line: 13, column: 12, scope: !32, inlinedAt: !84)
248!84 = distinct !DILocation(line: 17, column: 18, scope: !54, inlinedAt: !76)
249!85 = !DILocation(line: 14, column: 37, scope: !32, inlinedAt: !84)
250!86 = !DILocation(line: 14, column: 14, scope: !32, inlinedAt: !84)
251!87 = !DILocation(line: 22, column: 7, scope: !68)
252!88 = !DILocation(line: 14, column: 5, scope: !32, inlinedAt: !84)
253!89 = !DILocation(line: 15, column: 6, scope: !32, inlinedAt: !84)
254!90 = !DILocation(line: 15, column: 3, scope: !32, inlinedAt: !84)
255!91 = !DILocation(line: 16, column: 1, scope: !32, inlinedAt: !84)
256!92 = !DILocation(line: 23, column: 1, scope: !68)
257
258