1 # RUN: llc -run-pass wasm-reg-stackify %s -o - | FileCheck %s
4 target triple = "wasm32-unknown-unknown"
8 define void @sink_same_bb() {
11 define void @clone_same_bb() {
14 define void @clone_different_bb_0() {
17 define void @clone_different_bb_1() {
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)
35 # Sinking within the same BB preserves the debug location.
36 # CHECK-LABEL: name: sink_same_bb
39 - { reg: '$arguments' }
40 tracksRegLiveness: true
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
54 # Cloning within the same BB preserves the debug location.
55 # CHECK-LABEL: name: clone_same_bb
58 - { reg: '$arguments' }
59 tracksRegLiveness: true
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
70 ; CHECK-NEXT: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10
71 ; CHECK-NEXT: CALL @use
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
78 # CHECK-LABEL: name: clone_different_bb_0
79 name: clone_different_bb_0
81 - { reg: '$arguments' }
82 tracksRegLiveness: true
87 %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
88 BR %bb.1, implicit-def $arguments
92 CALL @use, %0:i32, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
93 RETURN implicit-def $arguments
96 ; CHECK: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10
97 ; CHECK-NEXT: CALL @use, %1, {{.*}}, debug-location !DILocation(line: 10
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
107 - { reg: '$arguments' }
108 tracksRegLiveness: true
113 %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)
114 BR %bb.1, implicit-def $arguments
117 ; predecessors: %bb.0
118 CALL @use, %0:i32, implicit-def $arguments, debug-location !DILocation(line:20, scope:!6)
119 RETURN implicit-def $arguments
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