[RISCV] Use getSignedConstant for negative values. (#125903)
[llvm-project.git] / llvm / test / DebugInfo / WebAssembly / dbg-loc-reg-stackify.mir
blob7b4b500e808a6a5c6bd64c53a5cf38d3e705906f
1 # RUN: llc -run-pass wasm-reg-stackify %s -o - | FileCheck %s
3 --- |
4   target triple = "wasm32-unknown-unknown"
6   declare void @use(i32)
8   define void @sink_same_bb() {
9     unreachable
10   }
11   define void @clone_same_bb() {
12     unreachable
13   }
14   define void @clone_different_bb_0() {
15     unreachable
16   }
17   define void @clone_different_bb_1() {
18     unreachable
19   }
21   !llvm.dbg.cu = !{!0}
22   !llvm.module.flags = !{!2, !3, !4}
24   !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
25   !1 = !DIFile(filename: "test.c", directory: "")
26   !2 = !{i32 7, !"Dwarf Version", i32 5}
27   !3 = !{i32 2, !"Debug Info Version", i32 3}
28   !4 = !{i32 1, !"wchar_size", i32 4}
29   !6 = distinct !DISubprogram(name: "sink_same_bb", scope: !1, file: !1, line: 1, type: !7, scopeLine: 1, unit: !0)
30   !7 = !DISubroutineType(types: !8)
31   !8 = !{null}
32 ...
34 ---
35 # Sinking within the same BB preserves the debug location.
36 # CHECK-LABEL: name: sink_same_bb
37 name: sink_same_bb
38 liveins:
39   - { reg: '$arguments' }
40 tracksRegLiveness: true
41 body: |
42   bb.0:
43     liveins: $arguments
44     %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
45     NOP implicit-def $arguments
46     CALL @use, %0:i32, implicit-def $arguments
47     RETURN implicit-def $arguments
49   ; CHECK:      %0:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10
50   ; CHECK-NEXT: CALL @use
51 ...
53 ---
54 # Cloning within the same BB preserves the debug location.
55 # CHECK-LABEL: name: clone_same_bb
56 name: clone_same_bb
57 liveins:
58   - { reg: '$arguments' }
59 tracksRegLiveness: true
60 body: |
61   bb.0:
62     liveins: $arguments
63     %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
64     NOP implicit-def $arguments
65     CALL @use, %0:i32, implicit-def $arguments
66     CALL @use, %0:i32, implicit-def $arguments
67     RETURN implicit-def $arguments
69   ; CHECK:      CALL @use
70   ; CHECK-NEXT: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10
71   ; CHECK-NEXT: CALL @use
72 ...
74 ---
75 # Cloning to a different BB preserves the debug location in this case because
76 # the destination BB has an instruction that has the same debug location
77 # (test.c:10).
78 # CHECK-LABEL: name: clone_different_bb_0
79 name: clone_different_bb_0
80 liveins:
81   - { reg: '$arguments' }
82 tracksRegLiveness: true
83 body: |
84   bb.0:
85     successors: %bb.1
86     liveins: $arguments
87     %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
88     BR %bb.1, implicit-def $arguments
90   bb.1:
91   ; predecessors: %bb.0
92     CALL @use, %0:i32, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
93     RETURN implicit-def $arguments
95   ; CHECK: bb.1:
96   ; CHECK:      %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10
97   ; CHECK-NEXT: CALL @use, %1, {{.*}}, debug-location !DILocation(line: 10
98 ...
101 # Cloning to a different BB does NOT preserve the debug location in this case
102 # because the destination BB doesn't have an instruction that has the same debug
103 # location (It has test.c:20 but not test.c:10).
104 # CHECK-LABEL: name: clone_different_bb_1
105 name: clone_different_bb_1
106 liveins:
107   - { reg: '$arguments' }
108 tracksRegLiveness: true
109 body: |
110   bb.0:
111     successors: %bb.1
112     liveins: $arguments
113     %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
114     BR %bb.1, implicit-def $arguments
116   bb.1:
117   ; predecessors: %bb.0
118     CALL @use, %0:i32, implicit-def $arguments, debug-location !DILocation(line:20, scope:!6)
119     RETURN implicit-def $arguments
121   ; CHECK: bb.1:
122   ; CHECK:      %1:i32 = CONST_I32 1
123   ; CHECK-NOT:  %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10
124   ; CHECK-NEXT: CALL @use, %1, {{.*}}, debug-location !DILocation(line: 20