126 lines · plain
1# RUN: llc -run-pass wasm-reg-stackify %s -o - | FileCheck %s2 3--- |4 target triple = "wasm32-unknown-unknown"5 6 declare void @use(i32)7 8 define void @sink_same_bb() {9 unreachable10 }11 define void @clone_same_bb() {12 unreachable13 }14 define void @clone_different_bb_0() {15 unreachable16 }17 define void @clone_different_bb_1() {18 unreachable19 }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_bb37name: sink_same_bb38liveins:39 - { reg: '$arguments' }40tracksRegLiveness: true41body: |42 bb.0:43 liveins: $arguments44 %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)45 NOP implicit-def $arguments46 CALL @use, %0:i32, implicit-def $arguments47 RETURN implicit-def $arguments48 49 ; CHECK: %0:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 1050 ; CHECK-NEXT: CALL @use51...52 53---54# Cloning within the same BB preserves the debug location.55# CHECK-LABEL: name: clone_same_bb56name: clone_same_bb57liveins:58 - { reg: '$arguments' }59tracksRegLiveness: true60body: |61 bb.0:62 liveins: $arguments63 %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)64 NOP implicit-def $arguments65 CALL @use, %0:i32, implicit-def $arguments66 CALL @use, %0:i32, implicit-def $arguments67 RETURN implicit-def $arguments68 69 ; CHECK: CALL @use70 ; CHECK-NEXT: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 1071 ; CHECK-NEXT: CALL @use72...73 74---75# Cloning to a different BB preserves the debug location in this case because76# the destination BB has an instruction that has the same debug location77# (test.c:10).78# CHECK-LABEL: name: clone_different_bb_079name: clone_different_bb_080liveins:81 - { reg: '$arguments' }82tracksRegLiveness: true83body: |84 bb.0:85 successors: %bb.186 liveins: $arguments87 %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)88 BR %bb.1, implicit-def $arguments89 90 bb.1:91 ; predecessors: %bb.092 CALL @use, %0:i32, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)93 RETURN implicit-def $arguments94 95 ; CHECK: bb.1:96 ; CHECK: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 1097 ; CHECK-NEXT: CALL @use, %1, {{.*}}, debug-location !DILocation(line: 1098...99 100---101# Cloning to a different BB does NOT preserve the debug location in this case102# because the destination BB doesn't have an instruction that has the same debug103# location (It has test.c:20 but not test.c:10).104# CHECK-LABEL: name: clone_different_bb_1105name: clone_different_bb_1106liveins:107 - { reg: '$arguments' }108tracksRegLiveness: true109body: |110 bb.0:111 successors: %bb.1112 liveins: $arguments113 %0:i32 = CONST_I32 1, implicit-def $arguments, debug-location !DILocation(line:10, scope:!6)114 BR %bb.1, implicit-def $arguments115 116 bb.1:117 ; predecessors: %bb.0118 CALL @use, %0:i32, implicit-def $arguments, debug-location !DILocation(line:20, scope:!6)119 RETURN implicit-def $arguments120 121 ; CHECK: bb.1:122 ; CHECK: %1:i32 = CONST_I32 1123 ; CHECK-NOT: %1:i32 = CONST_I32 1, {{.*}}, debug-location !DILocation(line: 10124 ; CHECK-NEXT: CALL @use, %1, {{.*}}, debug-location !DILocation(line: 20125...126