xref: /aosp_15_r20/external/llvm/test/DebugInfo/ARM/single-constant-use-preserves-dbgloc.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -filetype=asm -asm-verbose=0 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; int main()
4*9880d681SAndroid Build Coastguard Worker; {
5*9880d681SAndroid Build Coastguard Worker;     int x = 0;
6*9880d681SAndroid Build Coastguard Worker;     if (x > 0)
7*9880d681SAndroid Build Coastguard Worker;         return x;
8*9880d681SAndroid Build Coastguard Worker;     x = -1; // <== this line should have correct debug location
9*9880d681SAndroid Build Coastguard Worker;     return -1;
10*9880d681SAndroid Build Coastguard Worker; }
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK: .loc 1 6 7
13*9880d681SAndroid Build Coastguard Worker; CHECK: mvn
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
16*9880d681SAndroid Build Coastguard Workertarget triple = "armv7--linux-gnueabihf"
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind
19*9880d681SAndroid Build Coastguard Workerdefine i32 @main() !dbg !4 {
20*9880d681SAndroid Build Coastguard Workerentry:
21*9880d681SAndroid Build Coastguard Worker  %retval = alloca i32, align 4
22*9880d681SAndroid Build Coastguard Worker  %x = alloca i32, align 4
23*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %retval
24*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %x, metadata !10, metadata !11), !dbg !12
25*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %x, align 4, !dbg !12
26*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %x, align 4, !dbg !13
27*9880d681SAndroid Build Coastguard Worker  %cmp = icmp sgt i32 %0, 0, !dbg !15
28*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %if.then, label %if.end, !dbg !16
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %entry
31*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* %x, align 4, !dbg !17
32*9880d681SAndroid Build Coastguard Worker  store i32 %1, i32* %retval, !dbg !18
33*9880d681SAndroid Build Coastguard Worker  br label %return, !dbg !18
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workerif.end:                                           ; preds = %entry
36*9880d681SAndroid Build Coastguard Worker  store i32 -1, i32* %x, align 4, !dbg !19
37*9880d681SAndroid Build Coastguard Worker  store i32 -1, i32* %retval, !dbg !20
38*9880d681SAndroid Build Coastguard Worker  br label %return, !dbg !20
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %if.end, %if.then
41*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %retval, !dbg !21
42*9880d681SAndroid Build Coastguard Worker  ret i32 %2, !dbg !21
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
46*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata)
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
49*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!8, !9}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, emissionKind: FullDebug)
52*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "test.c", directory: "/home/user/clang/build")
53*9880d681SAndroid Build Coastguard Worker!2 = !{}
54*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, variables: !2)
55*9880d681SAndroid Build Coastguard Worker!5 = !DISubroutineType(types: !6)
56*9880d681SAndroid Build Coastguard Worker!6 = !{!7}
57*9880d681SAndroid Build Coastguard Worker!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
58*9880d681SAndroid Build Coastguard Worker!8 = !{i32 2, !"Dwarf Version", i32 4}
59*9880d681SAndroid Build Coastguard Worker!9 = !{i32 2, !"Debug Info Version", i32 3}
60*9880d681SAndroid Build Coastguard Worker!10 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 3, type: !7)
61*9880d681SAndroid Build Coastguard Worker!11 = !DIExpression()
62*9880d681SAndroid Build Coastguard Worker!12 = !DILocation(line: 3, column: 9, scope: !4)
63*9880d681SAndroid Build Coastguard Worker!13 = !DILocation(line: 4, column: 9, scope: !14)
64*9880d681SAndroid Build Coastguard Worker!14 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 9)
65*9880d681SAndroid Build Coastguard Worker!15 = !DILocation(line: 4, column: 11, scope: !14)
66*9880d681SAndroid Build Coastguard Worker!16 = !DILocation(line: 4, column: 9, scope: !4)
67*9880d681SAndroid Build Coastguard Worker!17 = !DILocation(line: 5, column: 13, scope: !14)
68*9880d681SAndroid Build Coastguard Worker!18 = !DILocation(line: 5, column: 9, scope: !14)
69*9880d681SAndroid Build Coastguard Worker!19 = !DILocation(line: 6, column: 7, scope: !4)
70*9880d681SAndroid Build Coastguard Worker!20 = !DILocation(line: 7, column: 5, scope: !4)
71*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 8, column: 1, scope: !4)
72