xref: /llvm-project/llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1# RUN: llc -run-pass=mir-debugify -o - %s | FileCheck --check-prefixes=ALL,VALUE %s
2# RUN: llc -run-pass=mir-debugify -debugify-level=locations -o - %s | FileCheck --check-prefixes=ALL --implicit-check-not=dbg.value %s
3# RUN: llc -run-pass=mir-debugify,mir-strip-debug,mir-debugify -o - %s | FileCheck --check-prefixes=ALL,VALUE %s
4# RUN: llc -run-pass=mir-debugify,mir-strip-debug -o - %s | FileCheck --check-prefix=STRIP %s
5# RUN: llc --experimental-debuginfo-iterators=false -run-pass=mir-debugify -o - %s | FileCheck --check-prefixes=ALL,VALUE %s
6# RUN: llc --experimental-debuginfo-iterators=false -run-pass=mir-debugify -debugify-level=locations -o - %s | FileCheck --check-prefixes=ALL --implicit-check-not=dbg.value %s
7# RUN: llc --experimental-debuginfo-iterators=false -run-pass=mir-debugify,mir-strip-debug,mir-debugify -o - %s | FileCheck --check-prefixes=ALL,VALUE %s
8# RUN: llc --experimental-debuginfo-iterators=false -run-pass=mir-debugify,mir-strip-debug -o - %s | FileCheck --check-prefix=STRIP %s
9
10--- |
11  ; ModuleID = 'loc-only.ll'
12  source_filename = "loc-only.ll"
13
14  ; ALL-LABEL: @test
15  define i32 @test(i32 %a, i32 %b) {
16    %add = add i32 %a, 2
17  ; ALL-NEXT:  %add = add i32 %a, 2, !dbg [[L1:![0-9]+]]
18  ; VALUE-NEXT: #dbg_value(i32 %add, [[add:![0-9]+]], !DIExpression(), [[L1]]
19    %sub = sub i32 %add, %b
20  ; ALL-NEXT: %sub = sub i32 %add, %b, !dbg [[L2:![0-9]+]]
21  ; VALUE-NEXT: #dbg_value(i32 %sub, [[sub:![0-9]+]], !DIExpression(), [[L2]]
22  ; ALL-NEXT: ret i32 %sub, !dbg [[L3:![0-9]+]]
23    ret i32 %sub
24  }
25
26  ; ALL: !llvm.dbg.cu = !{![[CU:[0-9]+]]}
27  ; ALL: !llvm.debugify =
28  ; ALL: !llvm.module.flags = !{![[VERSION:[0-9]+]]}
29  ; ALL: ![[CU]] = distinct !DICompileUnit(
30  ; ALL: ![[VERSION]] = !{i32 2, !"Debug Info Version", i32 3}
31  ; VALUE: [[VAR1:![0-9]+]] = !DILocalVariable(name: "1"
32  ; VALUE: [[VAR2:![0-9]+]] = !DILocalVariable(name: "2"
33  ; STRIP-NOT: !llvm.debugify
34  ; STRIP-NOT: !llvm.mir.debugify
35
36...
37---
38name:            test
39body:             |
40  bb.1 (%ir-block.0):
41    %0:_(s32) = IMPLICIT_DEF
42    %1:_(s32) = IMPLICIT_DEF
43    %2:_(s32) = G_CONSTANT i32 2
44    %3:_(s32) = G_ADD %0, %2
45    %4:_(s32) = G_SUB %3, %1
46    ; There's no attempt to have the locations make sense as it's an imaginary
47    ; source file anyway. These first three coincide with IR-level information
48    ; and therefore use metadata references.
49    ; ALL: %0:_(s32) = IMPLICIT_DEF debug-location [[L1]]
50    ; VALUE: DBG_VALUE %0(s32), $noreg, [[VAR1]], !DIExpression(), debug-location [[L1]]
51    ; ALL: %1:_(s32) = IMPLICIT_DEF debug-location [[L2]]
52    ; VALUE: DBG_VALUE %1(s32), $noreg, [[VAR2]], !DIExpression(), debug-location [[L2]]
53    ; ALL: %2:_(s32) = G_CONSTANT i32 2, debug-location [[L3]]
54    ; VALUE: DBG_VALUE %2(s32), $noreg, [[VAR1]], !DIExpression(), debug-location [[L3]]
55    ; ALL: %3:_(s32) = G_ADD %0, %2, debug-location !DILocation(line: 4, column: 1, scope: [[SP:![0-9]+]])
56    ; VALUE: DBG_VALUE %3(s32), $noreg, [[VAR1]], !DIExpression(), debug-location !DILocation(line: 4
57    ; ALL: %4:_(s32) = G_SUB %3, %1, debug-location !DILocation(line: 5, column: 1, scope: [[SP]])
58    ; VALUE: DBG_VALUE %4(s32), $noreg, [[VAR1]], !DIExpression(), debug-location !DILocation(line: 5
59...
60