xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/frame-order.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=x86_64-linux-gnueabi -disable-debug-info-print < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: opt -strip -S < %s | llc -mtriple=x86_64-linux-gnueabi -disable-debug-info-print | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; This test checks if the code is generated correctly with and without debug info.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; This LL file was generated by running 'clang -g -gcodeview' on the
7*9880d681SAndroid Build Coastguard Worker; following code:
8*9880d681SAndroid Build Coastguard Worker;  1: extern "C" volatile int x;
9*9880d681SAndroid Build Coastguard Worker;  2: extern "C" void capture(int *p);
10*9880d681SAndroid Build Coastguard Worker;  3: static __forceinline inline void will_be_inlined() {
11*9880d681SAndroid Build Coastguard Worker;  4:   int v = 3;
12*9880d681SAndroid Build Coastguard Worker;  5:   capture(&v);
13*9880d681SAndroid Build Coastguard Worker;  6: }
14*9880d681SAndroid Build Coastguard Worker;  7: extern "C" void f(int param) {
15*9880d681SAndroid Build Coastguard Worker;  8:   if (param) {
16*9880d681SAndroid Build Coastguard Worker;  9:     int a = 42;
17*9880d681SAndroid Build Coastguard Worker; 10:     will_be_inlined();
18*9880d681SAndroid Build Coastguard Worker; 11:     capture(&a);
19*9880d681SAndroid Build Coastguard Worker; 12:   } else {
20*9880d681SAndroid Build Coastguard Worker; 13:     int b = 42;
21*9880d681SAndroid Build Coastguard Worker; 14:     will_be_inlined();
22*9880d681SAndroid Build Coastguard Worker; 15:     capture(&b);
23*9880d681SAndroid Build Coastguard Worker; 16:   }
24*9880d681SAndroid Build Coastguard Worker; 17: }
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker; ModuleID = 't.cpp'
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
29*9880d681SAndroid Build Coastguard Workerdefine void @f(i32 %param) #0 !dbg !4 {
30*9880d681SAndroid Build Coastguard Workerentry:
31*9880d681SAndroid Build Coastguard Worker  %v.i1 = alloca i32, align 4
32*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %v.i1, metadata !15, metadata !16), !dbg !17
33*9880d681SAndroid Build Coastguard Worker  %v.i = alloca i32, align 4
34*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %v.i, metadata !15, metadata !16), !dbg !21
35*9880d681SAndroid Build Coastguard Worker  %param.addr = alloca i32, align 4
36*9880d681SAndroid Build Coastguard Worker  %a = alloca i32, align 4
37*9880d681SAndroid Build Coastguard Worker  %b = alloca i32, align 4
38*9880d681SAndroid Build Coastguard Worker  store i32 %param, i32* %param.addr, align 4
39*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %param.addr, metadata !24, metadata !16), !dbg !25
40*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %param.addr, align 4, !dbg !26
41*9880d681SAndroid Build Coastguard Worker  %tobool = icmp ne i32 %0, 0, !dbg !26
42*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %if.then, label %if.else, !dbg !27
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker;CHECK: movl [[REG:.*]], 20(%rsp)
45*9880d681SAndroid Build Coastguard Worker;CHECK: je [[LABEL:.*]]
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %entry
48*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %a, metadata !28, metadata !16), !dbg !29
49*9880d681SAndroid Build Coastguard Worker  store i32 42, i32* %a, align 4, !dbg !29
50*9880d681SAndroid Build Coastguard Worker  store i32 3, i32* %v.i, align 4, !dbg !21
51*9880d681SAndroid Build Coastguard Worker  call void @capture(i32* %v.i) #3, !dbg !30
52*9880d681SAndroid Build Coastguard Worker  call void @capture(i32* %a), !dbg !31
53*9880d681SAndroid Build Coastguard Worker  br label %if.end, !dbg !32
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker;CHECK: movl    $3, 12(%rsp)
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Workerif.else:                                          ; preds = %entry
58*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %b, metadata !33, metadata !16), !dbg !34
59*9880d681SAndroid Build Coastguard Worker  store i32 42, i32* %b, align 4, !dbg !34
60*9880d681SAndroid Build Coastguard Worker  store i32 3, i32* %v.i1, align 4, !dbg !17
61*9880d681SAndroid Build Coastguard Worker  call void @capture(i32* %v.i1) #3, !dbg !35
62*9880d681SAndroid Build Coastguard Worker  call void @capture(i32* %b), !dbg !36
63*9880d681SAndroid Build Coastguard Worker  br label %if.end
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Worker;CHECK: [[LABEL]]:
66*9880d681SAndroid Build Coastguard Worker;CHECK: movl    $3, 16(%rsp)
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Workerif.end:                                           ; preds = %if.else, %if.then
69*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !37
70*9880d681SAndroid Build Coastguard Worker}
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
73*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Workerdeclare void @capture(i32*) #2
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
78*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
79*9880d681SAndroid Build Coastguard Workerattributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
80*9880d681SAndroid Build Coastguard Workerattributes #3 = { nounwind }
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
83*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!11, !12, !13}
84*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!14}
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
87*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
88*9880d681SAndroid Build Coastguard Worker!2 = !{}
89*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
90*9880d681SAndroid Build Coastguard Worker!5 = !DISubroutineType(types: !6)
91*9880d681SAndroid Build Coastguard Worker!6 = !{null, !7}
92*9880d681SAndroid Build Coastguard Worker!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
93*9880d681SAndroid Build Coastguard Worker!8 = distinct !DISubprogram(name: "will_be_inlined", linkageName: "\01?will_be_inlined@@YAXXZ", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
94*9880d681SAndroid Build Coastguard Worker!9 = !DISubroutineType(types: !10)
95*9880d681SAndroid Build Coastguard Worker!10 = !{null}
96*9880d681SAndroid Build Coastguard Worker!11 = !{i32 2, !"CodeView", i32 1}
97*9880d681SAndroid Build Coastguard Worker!12 = !{i32 2, !"Debug Info Version", i32 3}
98*9880d681SAndroid Build Coastguard Worker!13 = !{i32 1, !"PIC Level", i32 2}
99*9880d681SAndroid Build Coastguard Worker!14 = !{!"clang version 3.9.0 "}
100*9880d681SAndroid Build Coastguard Worker!15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !7)
101*9880d681SAndroid Build Coastguard Worker!16 = !DIExpression()
102*9880d681SAndroid Build Coastguard Worker!17 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !18)
103*9880d681SAndroid Build Coastguard Worker!18 = distinct !DILocation(line: 14, column: 5, scope: !19)
104*9880d681SAndroid Build Coastguard Worker!19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 12, column: 10)
105*9880d681SAndroid Build Coastguard Worker!20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
106*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !22)
107*9880d681SAndroid Build Coastguard Worker!22 = distinct !DILocation(line: 10, column: 5, scope: !23)
108*9880d681SAndroid Build Coastguard Worker!23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8, column: 14)
109*9880d681SAndroid Build Coastguard Worker!24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !7)
110*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 7, column: 23, scope: !4)
111*9880d681SAndroid Build Coastguard Worker!26 = !DILocation(line: 8, column: 7, scope: !20)
112*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 8, column: 7, scope: !4)
113*9880d681SAndroid Build Coastguard Worker!28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !7)
114*9880d681SAndroid Build Coastguard Worker!29 = !DILocation(line: 9, column: 9, scope: !23)
115*9880d681SAndroid Build Coastguard Worker!30 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !22)
116*9880d681SAndroid Build Coastguard Worker!31 = !DILocation(line: 11, column: 5, scope: !23)
117*9880d681SAndroid Build Coastguard Worker!32 = !DILocation(line: 12, column: 3, scope: !23)
118*9880d681SAndroid Build Coastguard Worker!33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !7)
119*9880d681SAndroid Build Coastguard Worker!34 = !DILocation(line: 13, column: 9, scope: !19)
120*9880d681SAndroid Build Coastguard Worker!35 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !18)
121*9880d681SAndroid Build Coastguard Worker!36 = !DILocation(line: 15, column: 5, scope: !19)
122*9880d681SAndroid Build Coastguard Worker!37 = !DILocation(line: 17, column: 1, scope: !4)
123