diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 3 | ||||
-rw-r--r-- | test/passes/rereloop.txt | 47 | ||||
-rw-r--r-- | test/passes/rereloop.wast | 21 |
3 files changed, 67 insertions, 4 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 5935e9993..b2218993c 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -427,6 +427,9 @@ void test_relooper() { RelooperRef relooper = RelooperCreate(); BinaryenExpressionRef temp = makeInt32(module, -99); RelooperBlockRef block0 = RelooperAddBlockWithSwitch(relooper, makeCallCheck(module, 0), temp); + // TODO: this example is not very good, the blocks should end in a |return| as otherwise they + // fall through to each other. A relooper block should end in something that stops control + // flow, if it doesn't have branches going out RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); RelooperBlockRef block3 = RelooperAddBlock(relooper, makeCallCheck(module, 3)); diff --git a/test/passes/rereloop.txt b/test/passes/rereloop.txt index c15934c0b..17a084395 100644 --- a/test/passes/rereloop.txt +++ b/test/passes/rereloop.txt @@ -541,7 +541,6 @@ (block (br $block$3$break) ) - (br $switch$1$leave) ) (block (block @@ -552,7 +551,6 @@ ) ) ) - (br $switch$1$leave) ) ) (block @@ -572,7 +570,6 @@ (block (br $block$6$break) ) - (br $switch$3$leave) ) (block (block @@ -586,7 +583,6 @@ ) ) ) - (br $switch$3$leave) ) ) (block @@ -704,4 +700,47 @@ ) ) ) + (func $switcher-to-nowhere (type $2) (param $0 i32) (result i32) + (local $1 i32) + (block + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$4 + (br_table $switch$1$case$4 $switch$1$case$3 $switch$1$default + (get_local $0) + ) + ) + (block + (block + (block + (return + (i32.const 1) + ) + ) + ) + ) + ) + (block + (block + (block + (return + (i32.const 2) + ) + ) + ) + ) + ) + (block + (block + (block + (return + (i32.const 3) + ) + ) + ) + ) + ) + ) ) diff --git a/test/passes/rereloop.wast b/test/passes/rereloop.wast index 38c74ff56..0680c97fe 100644 --- a/test/passes/rereloop.wast +++ b/test/passes/rereloop.wast @@ -175,5 +175,26 @@ (i32.const 3) ) ) + + (func $switcher-to-nowhere (param $0 i32) (result i32) + (block $switch + (block $switch-case0 + (block $switch-case + (br_table $switch-case $switch-case0 $switch + (get_local $0) + ) + ) + (return + (i32.const 1) + ) + ) + (return + (i32.const 2) + ) + ) + (return + (i32.const 3) + ) + ) ) |