xref: /aosp_15_r20/external/llvm/test/Transforms/Inline/alloca-dbgdeclare.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -inline -S < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; struct A {
3*9880d681SAndroid Build Coastguard Worker;   int arg0;
4*9880d681SAndroid Build Coastguard Worker;   double arg1[2];
5*9880d681SAndroid Build Coastguard Worker; } a, b;
6*9880d681SAndroid Build Coastguard Worker;
7*9880d681SAndroid Build Coastguard Worker; void fn3(A p1) {
8*9880d681SAndroid Build Coastguard Worker;   if (p1.arg0)
9*9880d681SAndroid Build Coastguard Worker;     a = p1;
10*9880d681SAndroid Build Coastguard Worker; }
11*9880d681SAndroid Build Coastguard Worker;
12*9880d681SAndroid Build Coastguard Worker; void fn4() { fn3(b); }
13*9880d681SAndroid Build Coastguard Worker;
14*9880d681SAndroid Build Coastguard Worker; void fn5() {
15*9880d681SAndroid Build Coastguard Worker;   while (1)
16*9880d681SAndroid Build Coastguard Worker;     fn4();
17*9880d681SAndroid Build Coastguard Worker; }
18*9880d681SAndroid Build Coastguard Worker; ModuleID = 'test.cpp'
19*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
20*9880d681SAndroid Build Coastguard Workertarget triple = "aarch64-apple-darwin"
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker%struct.A = type { i32, [2 x double] }
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker@a = global %struct.A zeroinitializer, align 8
25*9880d681SAndroid Build Coastguard Worker@b = global %struct.A zeroinitializer, align 8
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
28*9880d681SAndroid Build Coastguard Workerdeclare void @_Z3fn31A(%struct.A* nocapture readonly %p1) #0
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
31*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
34*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #2
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
37*9880d681SAndroid Build Coastguard Workerdefine void @_Z3fn4v() #0 !dbg !21 {
38*9880d681SAndroid Build Coastguard Workerentry:
39*9880d681SAndroid Build Coastguard Worker; Test that the dbg.declare is moved together with the alloca.
40*9880d681SAndroid Build Coastguard Worker; CHECK: define void @_Z3fn5v()
41*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: entry:
42*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   %agg.tmp.sroa.3.i = alloca [20 x i8], align 4
43*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   call void @llvm.dbg.declare(metadata [20 x i8]* %agg.tmp.sroa.3.i,
44*9880d681SAndroid Build Coastguard Worker  %agg.tmp.sroa.3 = alloca [20 x i8], align 4
45*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.declare(metadata [20 x i8]* %agg.tmp.sroa.3, metadata !46, metadata !48), !dbg !49
46*9880d681SAndroid Build Coastguard Worker  %agg.tmp.sroa.0.0.copyload = load i32, i32* getelementptr inbounds (%struct.A, %struct.A* @b, i64 0, i32 0), align 8, !dbg !50
47*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32 %agg.tmp.sroa.0.0.copyload, i64 0, metadata !46, metadata !51), !dbg !49
48*9880d681SAndroid Build Coastguard Worker  %agg.tmp.sroa.3.0..sroa_idx = getelementptr inbounds [20 x i8], [20 x i8]* %agg.tmp.sroa.3, i64 0, i64 0, !dbg !50
49*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %agg.tmp.sroa.3.0..sroa_idx, i8* getelementptr (i8, i8* bitcast (%struct.A* @b to i8*), i64 4), i64 20, i32 4, i1 false), !dbg !50
50*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.declare(metadata %struct.A* undef, metadata !46, metadata !31) #2, !dbg !49
51*9880d681SAndroid Build Coastguard Worker  %tobool.i = icmp eq i32 %agg.tmp.sroa.0.0.copyload, 0, !dbg !52
52*9880d681SAndroid Build Coastguard Worker  br i1 %tobool.i, label %_Z3fn31A.exit, label %if.then.i, !dbg !53
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerif.then.i:                                        ; preds = %entry
55*9880d681SAndroid Build Coastguard Worker  store i32 %agg.tmp.sroa.0.0.copyload, i32* getelementptr inbounds (%struct.A, %struct.A* @a, i64 0, i32 0), align 8, !dbg !54
56*9880d681SAndroid Build Coastguard Worker  call void @llvm.memcpy.p0i8.p0i8.i64(i8* getelementptr (i8, i8* bitcast (%struct.A* @a to i8*), i64 4), i8* %agg.tmp.sroa.3.0..sroa_idx, i64 20, i32 4, i1 false), !dbg !54
57*9880d681SAndroid Build Coastguard Worker  br label %_Z3fn31A.exit, !dbg !54
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker_Z3fn31A.exit:                                    ; preds = %entry, %if.then.i
60*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !50
61*9880d681SAndroid Build Coastguard Worker}
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker; Function Attrs: noreturn nounwind
64*9880d681SAndroid Build Coastguard Workerdefine void @_Z3fn5v() #3 !dbg !24 {
65*9880d681SAndroid Build Coastguard Workerentry:
66*9880d681SAndroid Build Coastguard Worker  br label %while.body, !dbg !55
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerwhile.body:                                       ; preds = %entry, %while.body
69*9880d681SAndroid Build Coastguard Worker  call void @_Z3fn4v(), !dbg !56
70*9880d681SAndroid Build Coastguard Worker  br label %while.body, !dbg !55
71*9880d681SAndroid Build Coastguard Worker}
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
74*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind }
77*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
78*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind }
79*9880d681SAndroid Build Coastguard Workerattributes #3 = { noreturn nounwind }
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
82*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!28, !29}
83*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!30}
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.7.0 (trunk 227480) (llvm/trunk 227517)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !25, imports: !2)
86*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "<stdin>", directory: "")
87*9880d681SAndroid Build Coastguard Worker!2 = !{}
88*9880d681SAndroid Build Coastguard Worker!3 = !{!4}
89*9880d681SAndroid Build Coastguard Worker!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 1, size: 192, align: 64, file: !5, elements: !6, identifier: "_ZTS1A")
90*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "test.cpp", directory: "")
91*9880d681SAndroid Build Coastguard Worker!6 = !{!7, !9}
92*9880d681SAndroid Build Coastguard Worker!7 = !DIDerivedType(tag: DW_TAG_member, name: "arg0", line: 2, size: 32, align: 32, file: !5, scope: !4, baseType: !8)
93*9880d681SAndroid Build Coastguard Worker!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
94*9880d681SAndroid Build Coastguard Worker!9 = !DIDerivedType(tag: DW_TAG_member, name: "arg1", line: 3, size: 128, align: 64, offset: 64, file: !5, scope: !4, baseType: !10)
95*9880d681SAndroid Build Coastguard Worker!10 = !DICompositeType(tag: DW_TAG_array_type, size: 128, align: 64, baseType: !11, elements: !12)
96*9880d681SAndroid Build Coastguard Worker!11 = !DIBasicType(tag: DW_TAG_base_type, name: "double", size: 64, align: 64, encoding: DW_ATE_float)
97*9880d681SAndroid Build Coastguard Worker!12 = !{!13}
98*9880d681SAndroid Build Coastguard Worker!13 = !DISubrange(count: 2)
99*9880d681SAndroid Build Coastguard Worker!15 = distinct !DISubprogram(name: "fn3", linkageName: "_Z3fn31A", line: 6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 6, file: !5, scope: !16, type: !17, variables: !19)
100*9880d681SAndroid Build Coastguard Worker!16 = !DIFile(filename: "test.cpp", directory: "")
101*9880d681SAndroid Build Coastguard Worker!17 = !DISubroutineType(types: !18)
102*9880d681SAndroid Build Coastguard Worker!18 = !{null, !4}
103*9880d681SAndroid Build Coastguard Worker!19 = !{!20}
104*9880d681SAndroid Build Coastguard Worker!20 = !DILocalVariable(name: "p1", line: 6, arg: 1, scope: !15, file: !16, type: !4)
105*9880d681SAndroid Build Coastguard Worker!21 = distinct !DISubprogram(name: "fn4", linkageName: "_Z3fn4v", line: 11, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 11, file: !5, scope: !16, type: !22, variables: !2)
106*9880d681SAndroid Build Coastguard Worker!22 = !DISubroutineType(types: !23)
107*9880d681SAndroid Build Coastguard Worker!23 = !{null}
108*9880d681SAndroid Build Coastguard Worker!24 = distinct !DISubprogram(name: "fn5", linkageName: "_Z3fn5v", line: 13, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 13, file: !5, scope: !16, type: !22, variables: !2)
109*9880d681SAndroid Build Coastguard Worker!25 = !{!26, !27}
110*9880d681SAndroid Build Coastguard Worker!26 = !DIGlobalVariable(name: "a", line: 4, isLocal: false, isDefinition: true, scope: null, file: !16, type: !4, variable: %struct.A* @a)
111*9880d681SAndroid Build Coastguard Worker!27 = !DIGlobalVariable(name: "b", line: 4, isLocal: false, isDefinition: true, scope: null, file: !16, type: !4, variable: %struct.A* @b)
112*9880d681SAndroid Build Coastguard Worker!28 = !{i32 2, !"Dwarf Version", i32 4}
113*9880d681SAndroid Build Coastguard Worker!29 = !{i32 2, !"Debug Info Version", i32 3}
114*9880d681SAndroid Build Coastguard Worker!30 = !{!"clang version 3.7.0 (trunk 227480) (llvm/trunk 227517)"}
115*9880d681SAndroid Build Coastguard Worker!31 = !DIExpression(DW_OP_deref)
116*9880d681SAndroid Build Coastguard Worker!32 = !DILocation(line: 6, scope: !15)
117*9880d681SAndroid Build Coastguard Worker!33 = !DILocation(line: 7, scope: !34)
118*9880d681SAndroid Build Coastguard Worker!34 = distinct !DILexicalBlock(line: 7, column: 0, file: !5, scope: !15)
119*9880d681SAndroid Build Coastguard Worker!35 = !{!36, !37, i64 0}
120*9880d681SAndroid Build Coastguard Worker!36 = !{!4, !37, i64 0, !38, i64 8}
121*9880d681SAndroid Build Coastguard Worker!37 = !{!"int", !38, i64 0}
122*9880d681SAndroid Build Coastguard Worker!38 = !{!"omnipotent char", !39, i64 0}
123*9880d681SAndroid Build Coastguard Worker!39 = !{!"Simple C/C++ TBAA"}
124*9880d681SAndroid Build Coastguard Worker!40 = !DILocation(line: 7, scope: !15)
125*9880d681SAndroid Build Coastguard Worker!41 = !DILocation(line: 8, scope: !34)
126*9880d681SAndroid Build Coastguard Worker!42 = !{i64 0, i64 4, !43, i64 8, i64 16, !44}
127*9880d681SAndroid Build Coastguard Worker!43 = !{!37, !37, i64 0}
128*9880d681SAndroid Build Coastguard Worker!44 = !{!38, !38, i64 0}
129*9880d681SAndroid Build Coastguard Worker!45 = !DILocation(line: 9, scope: !15)
130*9880d681SAndroid Build Coastguard Worker!46 = !DILocalVariable(name: "p1", line: 6, arg: 1, scope: !15, file: !16, type: !4)
131*9880d681SAndroid Build Coastguard Worker!47 = distinct !DILocation(line: 11, scope: !21)
132*9880d681SAndroid Build Coastguard Worker!48 = !DIExpression(DW_OP_bit_piece, 32, 160)
133*9880d681SAndroid Build Coastguard Worker!49 = !DILocation(line: 6, scope: !15, inlinedAt: !47)
134*9880d681SAndroid Build Coastguard Worker!50 = !DILocation(line: 11, scope: !21)
135*9880d681SAndroid Build Coastguard Worker!51 = !DIExpression(DW_OP_bit_piece, 0, 32)
136*9880d681SAndroid Build Coastguard Worker!52 = !DILocation(line: 7, scope: !34, inlinedAt: !47)
137*9880d681SAndroid Build Coastguard Worker!53 = !DILocation(line: 7, scope: !15, inlinedAt: !47)
138*9880d681SAndroid Build Coastguard Worker!54 = !DILocation(line: 8, scope: !34, inlinedAt: !47)
139*9880d681SAndroid Build Coastguard Worker!55 = !DILocation(line: 14, scope: !24)
140*9880d681SAndroid Build Coastguard Worker!56 = !DILocation(line: 15, scope: !24)
141