86 lines · plain
1# RUN: llc -mtriple=wasm32-unknown-unknown -run-pass wasm-fix-irreducible-control-flow %s -o - | FileCheck %s2 3# This tests if we correctly create at most 2 routing blocks per entry block,4# and also whether those routing blocks are generated in the correct place. If5# one of the predecessor is the layout predecessor of an entry, a routing block6# for the entry should be generated right after the layout predecessor.7 8--- |9 target triple = "wasm32-unknown-unknown"10 11 define void @test0() {12 pred0:13 ret void14 pred1:15 ret void16 entry0:17 ret void18 entry1:19 ret void20 }21...22 23---24# CHECK-LABEL: test025name: test026liveins:27 - { reg: '$arguments' }28body: |29 bb.0.pred0:30 successors: %bb.1, %bb.231 liveins: $arguments32 %0:i32 = CONST_I32 100, implicit-def $arguments33 BR_IF %bb.2, %0:i32, implicit-def $arguments34 ; CHECK: bb.0.pred0:35 ; CHECK: %1:i32 = IMPLICIT_DEF36 ; CHECK-NEXT: %0:i32 = IMPLICIT_DEF37 ; CHECK: BR_IF %bb.2, %0, implicit-def $arguments38 39 bb.1.pred1:40 ; predecessors: %bb.141 successors: %bb.2, %bb.342 BR_IF %bb.3, %0:i32, implicit-def $arguments43 ; CHECK: bb.1.pred1:44 ; CHECK: BR_IF %bb.7, %0, implicit-def $arguments45 ; This falls through to bb.2, so we don't need an additional BR here46 ; CHECK-NOT: BR47 48 ; Routing block for entry0, when predecessor is outside the loop49 ; This routing block is shared between the two predecessors: pred0 and pred1.50 ; CHECK: bb.2:51 ; CHECK: %1:i32 = CONST_I32 0, implicit-def $arguments52 ; CHECK-NEXT: BR %bb.6, implicit-def $arguments53 54 bb.2.entry0:55 ; predecessors: %bb.0, %bb.1, %bb.156 successors: %bb.357 BR %bb.3, implicit-def $arguments58 ; CHECK: bb.3.entry0:59 ; CHECK: BR %bb.4, implicit-def $arguments60 61 ; Routing block for entry1, when predecessor is inside the loop62 ; CHECK: bb.4:63 ; CHECK: %1:i32 = CONST_I32 1, implicit-def $arguments64 ; CHECK-NEXT: BR %bb.6, implicit-def $arguments65 66 bb.3.entry1:67 ; predecessors: %bb.1, %bb.268 successors: %bb.269 BR %bb.2, implicit-def $arguments70 ; CHECK: bb.5.entry1:71 ; CHECK: BR %bb.8, implicit-def $arguments72 73 ; Dispatch block74 ; CHECK: bb.6:75 ; CHECK: BR_TABLE_I32 %1, %bb.3, %bb.5, %bb.5, implicit-def $arguments76 77 ; Routing block for entry1, when predecessor is outside the loop78 ; CHECK: bb.7:79 ; CHECK: %1:i32 = CONST_I32 1, implicit-def $arguments80 ; CHECK-NEXT: BR %bb.6, implicit-def $arguments81 82 ; Routing block for entry0, when predecessor is inside the loop83 ; CHECK: bb.8:84 ; CHECK: %1:i32 = CONST_I32 0, implicit-def $arguments85 ; CHECK-NEXT: BR %bb.6, implicit-def $arguments86