xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/dbg-combine.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple x86_64-pc-linux -O0 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Make sure that the sequence of debug locations for function foo is correctly
4*9880d681SAndroid Build Coastguard Worker; generated. More specifically, .loc entries for lines 4,5,6,7 must appear in
5*9880d681SAndroid Build Coastguard Worker; the correct sequence.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; $ clang -emit-llvm -S -g dbg-combine.c
8*9880d681SAndroid Build Coastguard Worker; 1.  int foo()
9*9880d681SAndroid Build Coastguard Worker; 2.  {
10*9880d681SAndroid Build Coastguard Worker; 3.     int elems = 3;
11*9880d681SAndroid Build Coastguard Worker; 4.     int array1[elems];
12*9880d681SAndroid Build Coastguard Worker; 5.     array1[0]=0;
13*9880d681SAndroid Build Coastguard Worker; 6.     array1[1]=1;
14*9880d681SAndroid Build Coastguard Worker; 7.     array1[2]=2;
15*9880d681SAndroid Build Coastguard Worker; 8.     int array2[elems];
16*9880d681SAndroid Build Coastguard Worker; 9.     array2[0]=1;
17*9880d681SAndroid Build Coastguard Worker; 10.    return array2[0];
18*9880d681SAndroid Build Coastguard Worker; 11. }
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker; CHECK: .loc    1 4
21*9880d681SAndroid Build Coastguard Worker; CHECK: .loc    1 5
22*9880d681SAndroid Build Coastguard Worker; CHECK: .loc    1 6
23*9880d681SAndroid Build Coastguard Worker; CHECK: .loc    1 7
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; ModuleID = 'dbg-combine.c'
26*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
27*9880d681SAndroid Build Coastguard Workerdefine i32 @foo() #0 !dbg !4 {
28*9880d681SAndroid Build Coastguard Workerentry:
29*9880d681SAndroid Build Coastguard Worker  %elems = alloca i32, align 4
30*9880d681SAndroid Build Coastguard Worker  %saved_stack = alloca i8*
31*9880d681SAndroid Build Coastguard Worker  %cleanup.dest.slot = alloca i32
32*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %elems, metadata !12, metadata !13), !dbg !14
33*9880d681SAndroid Build Coastguard Worker  store i32 3, i32* %elems, align 4, !dbg !14
34*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %elems, align 4, !dbg !15
35*9880d681SAndroid Build Coastguard Worker  %1 = zext i32 %0 to i64, !dbg !16
36*9880d681SAndroid Build Coastguard Worker  %2 = call i8* @llvm.stacksave(), !dbg !16
37*9880d681SAndroid Build Coastguard Worker  store i8* %2, i8** %saved_stack, !dbg !16
38*9880d681SAndroid Build Coastguard Worker  %vla = alloca i32, i64 %1, align 16, !dbg !16
39*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %vla, metadata !17, metadata !21), !dbg !22
40*9880d681SAndroid Build Coastguard Worker  %arrayidx = getelementptr inbounds i32, i32* %vla, i64 0, !dbg !23
41*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %arrayidx, align 4, !dbg !24
42*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds i32, i32* %vla, i64 1, !dbg !25
43*9880d681SAndroid Build Coastguard Worker  store i32 1, i32* %arrayidx1, align 4, !dbg !26
44*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds i32, i32* %vla, i64 2, !dbg !27
45*9880d681SAndroid Build Coastguard Worker  store i32 2, i32* %arrayidx2, align 4, !dbg !28
46*9880d681SAndroid Build Coastguard Worker  %3 = load i32, i32* %elems, align 4, !dbg !29
47*9880d681SAndroid Build Coastguard Worker  %4 = zext i32 %3 to i64, !dbg !30
48*9880d681SAndroid Build Coastguard Worker  %vla3 = alloca i32, i64 %4, align 16, !dbg !30
49*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %vla3, metadata !31, metadata !21), !dbg !32
50*9880d681SAndroid Build Coastguard Worker  %arrayidx4 = getelementptr inbounds i32, i32* %vla3, i64 0, !dbg !33
51*9880d681SAndroid Build Coastguard Worker  store i32 1, i32* %arrayidx4, align 4, !dbg !34
52*9880d681SAndroid Build Coastguard Worker  %arrayidx5 = getelementptr inbounds i32, i32* %vla3, i64 0, !dbg !35
53*9880d681SAndroid Build Coastguard Worker  %5 = load i32, i32* %arrayidx5, align 4, !dbg !35
54*9880d681SAndroid Build Coastguard Worker  store i32 1, i32* %cleanup.dest.slot
55*9880d681SAndroid Build Coastguard Worker  %6 = load i8*, i8** %saved_stack, !dbg !36
56*9880d681SAndroid Build Coastguard Worker  call void @llvm.stackrestore(i8* %6), !dbg !36
57*9880d681SAndroid Build Coastguard Worker  ret i32 %5, !dbg !36
58*9880d681SAndroid Build Coastguard Worker}
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
61*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
64*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.stacksave() #2
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
67*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.stackrestore(i8*) #2
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
70*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
71*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind }
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
74*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!9, !10}
75*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!11}
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.7.0 (trunk 227074)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
78*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "dbg-combine.c", directory: "/home/probinson/projects/scratch")
79*9880d681SAndroid Build Coastguard Worker!2 = !{}
80*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, variables: !2)
81*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "dbg-combine.c", directory: "/home/probinson/projects/scratch")
82*9880d681SAndroid Build Coastguard Worker!6 = !DISubroutineType(types: !7)
83*9880d681SAndroid Build Coastguard Worker!7 = !{!8}
84*9880d681SAndroid Build Coastguard Worker!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
85*9880d681SAndroid Build Coastguard Worker!9 = !{i32 2, !"Dwarf Version", i32 4}
86*9880d681SAndroid Build Coastguard Worker!10 = !{i32 2, !"Debug Info Version", i32 3}
87*9880d681SAndroid Build Coastguard Worker!11 = !{!"clang version 3.7.0 (trunk 227074)"}
88*9880d681SAndroid Build Coastguard Worker!12 = !DILocalVariable(name: "elems", line: 3, scope: !4, file: !5, type: !8)
89*9880d681SAndroid Build Coastguard Worker!13 = !DIExpression()
90*9880d681SAndroid Build Coastguard Worker!14 = !DILocation(line: 3, column: 8, scope: !4)
91*9880d681SAndroid Build Coastguard Worker!15 = !DILocation(line: 4, column: 15, scope: !4)
92*9880d681SAndroid Build Coastguard Worker!16 = !DILocation(line: 4, column: 4, scope: !4)
93*9880d681SAndroid Build Coastguard Worker!17 = !DILocalVariable(name: "array1", line: 4, scope: !4, file: !5, type: !18)
94*9880d681SAndroid Build Coastguard Worker!18 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !8, elements: !19)
95*9880d681SAndroid Build Coastguard Worker!19 = !{!20}
96*9880d681SAndroid Build Coastguard Worker!20 = !DISubrange(count: -1)
97*9880d681SAndroid Build Coastguard Worker!21 = !DIExpression(DW_OP_deref)
98*9880d681SAndroid Build Coastguard Worker!22 = !DILocation(line: 4, column: 8, scope: !4)
99*9880d681SAndroid Build Coastguard Worker!23 = !DILocation(line: 5, column: 4, scope: !4)
100*9880d681SAndroid Build Coastguard Worker!24 = !DILocation(line: 5, column: 13, scope: !4)
101*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 6, column: 4, scope: !4)
102*9880d681SAndroid Build Coastguard Worker!26 = !DILocation(line: 6, column: 13, scope: !4)
103*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 7, column: 4, scope: !4)
104*9880d681SAndroid Build Coastguard Worker!28 = !DILocation(line: 7, column: 13, scope: !4)
105*9880d681SAndroid Build Coastguard Worker!29 = !DILocation(line: 8, column: 15, scope: !4)
106*9880d681SAndroid Build Coastguard Worker!30 = !DILocation(line: 8, column: 4, scope: !4)
107*9880d681SAndroid Build Coastguard Worker!31 = !DILocalVariable(name: "array2", line: 8, scope: !4, file: !5, type: !18)
108*9880d681SAndroid Build Coastguard Worker!32 = !DILocation(line: 8, column: 8, scope: !4)
109*9880d681SAndroid Build Coastguard Worker!33 = !DILocation(line: 9, column: 4, scope: !4)
110*9880d681SAndroid Build Coastguard Worker!34 = !DILocation(line: 9, column: 13, scope: !4)
111*9880d681SAndroid Build Coastguard Worker!35 = !DILocation(line: 10, column: 11, scope: !4)
112*9880d681SAndroid Build Coastguard Worker!36 = !DILocation(line: 11, column: 1, scope: !4)
113