1# RUN: llc -run-pass wasm-reg-stackify %s -o - | FileCheck %s 2 3--- | 4 target triple = "wasm32-unknown-unknown" 5 6 declare void @use(i32) 7 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 } 20 21 !llvm.dbg.cu = !{!0} 22 !llvm.module.flags = !{!2, !3, !4} 23 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... 33 34--- 35# Sinking within the same BB preserves the debug location. 36# CHECK-LABEL: name: sink_same_bb 37name: sink_same_bb 38liveins: 39 - { reg: '$arguments' } 40tracksRegLiveness: true 41body: | 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 48 49 ; CHECK: %0:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10 50 ; CHECK-NEXT: CALL @use 51... 52 53--- 54# Cloning within the same BB preserves the debug location. 55# CHECK-LABEL: name: clone_same_bb 56name: clone_same_bb 57liveins: 58 - { reg: '$arguments' } 59tracksRegLiveness: true 60body: | 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 68 69 ; CHECK: CALL @use 70 ; CHECK-NEXT: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10 71 ; CHECK-NEXT: CALL @use 72... 73 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 79name: clone_different_bb_0 80liveins: 81 - { reg: '$arguments' } 82tracksRegLiveness: true 83body: | 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 89 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 94 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... 99 100--- 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 105name: clone_different_bb_1 106liveins: 107 - { reg: '$arguments' } 108tracksRegLiveness: true 109body: | 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 115 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 120 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 125... 126