diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-07-20 21:31:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 21:31:46 -0700 |
commit | 12abb63203788cba23f5c65a971a2af922e05bfc (patch) | |
tree | 47160f540810e408ccd74ae8e4b422afaf59e0fb /test/example | |
parent | 5e9058c9b108298406da7474c524e8d452431710 (diff) | |
parent | fa60ade30e03c6a13bbce26ff81c03ed1ae4da0b (diff) | |
download | binaryen-12abb63203788cba23f5c65a971a2af922e05bfc.tar.gz binaryen-12abb63203788cba23f5c65a971a2af922e05bfc.tar.bz2 binaryen-12abb63203788cba23f5c65a971a2af922e05bfc.zip |
Merge pull request #648 from WebAssembly/relooper-opts
Relooper improvements
Diffstat (limited to 'test/example')
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 97 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 1707 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt.txt | 600 | ||||
-rw-r--r-- | test/example/relooper-fuzz.c | 6 | ||||
-rw-r--r-- | test/example/relooper-fuzz.txt | 295 | ||||
-rw-r--r-- | test/example/relooper-fuzz1.c | 332 | ||||
-rw-r--r-- | test/example/relooper-fuzz1.txt | 501 |
7 files changed, 2805 insertions, 733 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 568492659..496ac4efd 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -270,37 +270,48 @@ void test_core() { BinaryenModuleDispose(module); } +BinaryenExpressionRef makeCallCheck(BinaryenModuleRef module, int x) { + BinaryenExpressionRef callOperands[] = { makeInt32(module, x) }; + return BinaryenCallImport(module, "check", callOperands, 1, BinaryenNone()); +} + void test_relooper() { BinaryenModuleRef module = BinaryenModuleCreate(); BinaryenFunctionTypeRef v = BinaryenAddFunctionType(module, "v", BinaryenNone(), NULL, 0); BinaryenType localTypes[] = { BinaryenInt32() }; + { + BinaryenType iparams[1] = { BinaryenInt32() }; + BinaryenFunctionTypeRef vi = BinaryenAddFunctionType(module, "vi", BinaryenNone(), iparams, 1); + BinaryenAddImport(module, "check", "module", "check", vi); + } + { // trivial: just one block RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block = RelooperAddBlock(relooper, makeSomething(module)); + RelooperBlockRef block = RelooperAddBlock(relooper, makeCallCheck(module, 1337)); BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block, 0, module); BinaryenFunctionRef sinker = BinaryenAddFunction(module, "just-one-block", v, localTypes, 1, body); } { // two blocks RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); RelooperAddBranch(block0, block1, NULL, NULL); // no condition, no code on branch BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module); BinaryenFunctionRef sinker = BinaryenAddFunction(module, "two-blocks", v, localTypes, 1, body); } { // two blocks with code between them RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); RelooperAddBranch(block0, block1, NULL, makeInt32(module, 77)); // code on branch BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module); BinaryenFunctionRef sinker = BinaryenAddFunction(module, "two-blocks-plus-code", v, localTypes, 1, body); } { // two blocks in a loop RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); RelooperAddBranch(block0, block1, NULL, NULL); RelooperAddBranch(block1, block0, NULL, NULL); BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module); @@ -308,8 +319,8 @@ void test_relooper() { } { // two blocks in a loop with codes RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); RelooperAddBranch(block0, block1, NULL, makeInt32(module, 33)); RelooperAddBranch(block1, block0, NULL, makeInt32(module, -66)); BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module); @@ -317,9 +328,9 @@ void test_relooper() { } { // split RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); RelooperAddBranch(block0, block1, makeInt32(module, 55), NULL); RelooperAddBranch(block0, block2, NULL, NULL); BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module); @@ -327,9 +338,9 @@ void test_relooper() { } { // split + code RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); BinaryenExpressionRef temp = makeInt32(module, 10); RelooperAddBranch(block0, block1, makeInt32(module, 55), temp); RelooperAddBranch(block0, block2, NULL, makeInt32(module, 20)); @@ -338,9 +349,9 @@ void test_relooper() { } { // if RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); RelooperAddBranch(block0, block1, makeInt32(module, 55), NULL); RelooperAddBranch(block0, block2, NULL, NULL); RelooperAddBranch(block1, block2, NULL, NULL); @@ -349,9 +360,9 @@ void test_relooper() { } { // if + code RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); BinaryenExpressionRef temp = makeInt32(module, -1); RelooperAddBranch(block0, block1, makeInt32(module, 55), temp); RelooperAddBranch(block0, block2, NULL, makeInt32(module, -2)); @@ -361,10 +372,10 @@ void test_relooper() { } { // if-else RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); - RelooperBlockRef block3 = RelooperAddBlock(relooper, makeInt32(module, 3)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); + RelooperBlockRef block3 = RelooperAddBlock(relooper, makeCallCheck(module, 3)); RelooperAddBranch(block0, block1, makeInt32(module, 55), NULL); RelooperAddBranch(block0, block2, NULL, NULL); RelooperAddBranch(block1, block3, NULL, NULL); @@ -374,9 +385,9 @@ void test_relooper() { } { // loop+tail RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); RelooperAddBranch(block0, block1, NULL, NULL); RelooperAddBranch(block1, block0, makeInt32(module, 10), NULL); RelooperAddBranch(block1, block2, NULL, NULL); @@ -385,13 +396,13 @@ void test_relooper() { } { // nontrivial loop + phi to head RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); - RelooperBlockRef block3 = RelooperAddBlock(relooper, makeInt32(module, 3)); - RelooperBlockRef block4 = RelooperAddBlock(relooper, makeInt32(module, 4)); - RelooperBlockRef block5 = RelooperAddBlock(relooper, makeInt32(module, 5)); - RelooperBlockRef block6 = RelooperAddBlock(relooper, makeInt32(module, 6)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); + RelooperBlockRef block3 = RelooperAddBlock(relooper, makeCallCheck(module, 3)); + RelooperBlockRef block4 = RelooperAddBlock(relooper, makeCallCheck(module, 4)); + RelooperBlockRef block5 = RelooperAddBlock(relooper, makeCallCheck(module, 5)); + RelooperBlockRef block6 = RelooperAddBlock(relooper, makeCallCheck(module, 6)); RelooperAddBranch(block0, block1, NULL, makeInt32(module, 10)); RelooperAddBranch(block1, block2, makeInt32(module, -2), NULL); RelooperAddBranch(block1, block6, NULL, makeInt32(module, 20)); @@ -407,10 +418,10 @@ void test_relooper() { { // switch RelooperRef relooper = RelooperCreate(); BinaryenExpressionRef temp = makeInt32(module, -99); - RelooperBlockRef block0 = RelooperAddBlockWithSwitch(relooper, makeInt32(module, 0), temp); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); - RelooperBlockRef block3 = RelooperAddBlock(relooper, makeInt32(module, 3)); + RelooperBlockRef block0 = RelooperAddBlockWithSwitch(relooper, makeCallCheck(module, 0), temp); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); + RelooperBlockRef block3 = RelooperAddBlock(relooper, makeCallCheck(module, 3)); BinaryenIndex to_block1[] = { 2, 5 }; RelooperAddBranchForSwitch(block0, block1, to_block1, 2, NULL); BinaryenIndex to_block2[] = { 4 }; @@ -421,9 +432,9 @@ void test_relooper() { } { // duff's device RelooperRef relooper = RelooperCreate(); - RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0)); - RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1)); - RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2)); + RelooperBlockRef block0 = RelooperAddBlock(relooper, makeCallCheck(module, 0)); + RelooperBlockRef block1 = RelooperAddBlock(relooper, makeCallCheck(module, 1)); + RelooperBlockRef block2 = RelooperAddBlock(relooper, makeCallCheck(module, 2)); RelooperAddBranch(block0, block1, makeInt32(module, 10), NULL); RelooperAddBranch(block0, block2, NULL, NULL); RelooperAddBranch(block1, block2, NULL, NULL); @@ -437,7 +448,7 @@ void test_relooper() { { // return in a block RelooperRef relooper = RelooperCreate(); - BinaryenExpressionRef listList[] = { makeInt32(module, 42), BinaryenReturn(module, makeInt32(module, 1337)) }; + BinaryenExpressionRef listList[] = { makeCallCheck(module, 42), BinaryenReturn(module, makeInt32(module, 1337)) }; BinaryenExpressionRef list = BinaryenBlock(module, "the-list", listList, 2); RelooperBlockRef block = RelooperAddBlock(relooper, list); BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block, 0, module); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index bd3b911f7..64f5fc3b4 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -370,40 +370,63 @@ raw: (module (memory 0) (type $v (func)) + (type $vi (func (param i32))) (type $i (func (result i32))) + (import $check "module" "check" (param i32)) (func $just-one-block (type $v) (local $0 i32) - (i32.const 1337) + (call_import $check + (i32.const 1337) + ) ) (func $two-blocks (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) ) ) (func $two-blocks-plus-code (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 77) + (br $block$2$break) ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) ) ) (func $loop (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) (block (br $shape$0$continue) ) @@ -412,15 +435,20 @@ raw: ) (func $loop-plus-code (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 33) + (br $block$2$break) ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) (block (i32.const -66) (br $shape$0$continue) @@ -430,14 +458,18 @@ raw: ) (func $split (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) ) - (block + ) + (block + (call_import $check (i32.const 2) ) ) @@ -445,19 +477,23 @@ raw: ) (func $split-plus-code (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (i32.const 10) (block - (i32.const 10) - (block + (call_import $check (i32.const 1) ) ) + ) + (block + (i32.const 20) (block - (i32.const 20) - (block + (call_import $check (i32.const 2) ) ) @@ -466,166 +502,197 @@ raw: ) (func $if (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (block $block$3$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) - (block - (br $shape$1$break) - ) + ) + (block + (br $block$3$break) ) ) + (br $block$3$break) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $if-plus-code (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) + (block $block$3$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (i32.const -1) (block - (i32.const -1) - (block + (call_import $check (i32.const 1) - (block - (i32.const -3) - (br $shape$1$break) - ) + ) + (block + (i32.const -3) + (br $block$3$break) ) ) + ) + (block (i32.const -2) + (br $block$3$break) ) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $if-else (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (block $block$4$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) - (block - (br $shape$1$break) - ) ) (block + (br $block$4$break) + ) + ) + (block + (call_import $check (i32.const 2) - (block - (br $shape$1$break) - ) + ) + (block + (br $block$4$break) ) ) ) ) (block - (i32.const 3) + (call_import $check + (i32.const 3) + ) ) ) (func $loop-tail (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) - ) - (block - (i32.const 1) - (if - (i32.const 10) - (br $shape$0$continue) - (br $shape$0$break) + (block $block$3$break + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) + ) + (block + (call_import $check + (i32.const 1) + ) + (if + (i32.const 10) + (br $shape$0$continue) + (br $block$3$break) + ) ) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $nontrivial-loop-plus-phi-to-head (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 10) + (br $block$2$break) ) ) (block - (loop $shape$1$break $shape$1$continue - (block - (i32.const 1) - (if - (i32.eqz - (i32.const -2) - ) - (block - (i32.const 20) - (br $shape$1$break) - ) - ) - ) - (block - (i32.const 2) - (if - (i32.const -6) - (block - (set_local $0 - (i32.const 4) + (block $block$7$break + (block $block$4$break + (loop $shape$1$continue + (block $block$3$break + (call_import $check + (i32.const 1) + ) + (if + (i32.const -2) + (br $block$3$break) + (block + (i32.const 20) + (br $block$7$break) + ) ) - (br $shape$1$break) ) (block - (i32.const 30) - (br $shape$1$continue) + (call_import $check + (i32.const 2) + ) + (if + (i32.const -6) + (br $block$4$break) + (block + (i32.const 30) + (br $shape$1$continue) + ) + ) ) ) ) - ) - (block - (block $shape$4$break - (if - (i32.eq - (get_local $0) - (i32.const 4) + (block + (block $block$6$break + (call_import $check + (i32.const 3) ) - (block + (if + (i32.const -10) (block - (i32.const 3) - (block $shape$6$break - (if - (i32.const -10) - (block - (i32.const 4) - (block - (br $shape$6$break) - ) - ) - ) + (call_import $check + (i32.const 4) ) - ) - (block - (i32.const 5) (block - (i32.const 40) - (br $shape$4$break) + (br $block$6$break) ) ) + (br $block$6$break) + ) + ) + (block + (call_import $check + (i32.const 5) + ) + (block + (i32.const 40) + (br $block$7$break) ) ) ) - (block + ) + (block + (call_import $check (i32.const 6) ) ) @@ -633,38 +700,44 @@ raw: ) (func $switch (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (block $switch$1$leave - (block $switch$1$default - (block $switch$1$case$3 - (block $switch$1$case$2 - (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default - (i32.const -99) - ) + (call_import $check + (i32.const 0) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$2 + (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default + (i32.const -99) ) + ) + (block (block - (block + (call_import $check (i32.const 1) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) + ) + (block + (i32.const 55) (block - (i32.const 55) - (block + (call_import $check (i32.const 2) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) + ) + (block (block - (block + (call_import $check (i32.const 3) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) ) ) (func $duffs-device (type $v) @@ -676,52 +749,66 @@ raw: (local $5 f64) (local $6 i32) (block - (i32.const 0) + (block $block$3$break + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 10) + (block + (set_local $3 + (i32.const 2) + ) + (br $block$2$break) + ) + (block + (set_local $3 + (i32.const 3) + ) + (br $block$3$break) + ) + ) + ) + ) + ) + (loop $shape$1$continue (if - (i32.const 10) - (set_local $3 + (i32.eq + (get_local $3) (i32.const 2) ) - (set_local $3 - (i32.const 3) + (block + (set_local $3 + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (block + (set_local $3 + (i32.const 3) + ) + (br $shape$1$continue) + ) ) - ) - ) - (loop $shape$1$break $shape$1$continue - (block $shape$2$break (if (i32.eq (get_local $3) - (i32.const 2) + (i32.const 3) ) (block (set_local $3 (i32.const 0) ) - (i32.const 1) - (block - (set_local $3 - (i32.const 3) - ) - (br $shape$1$continue) - ) - ) - (if - (i32.eq - (get_local $3) - (i32.const 3) + (call_import $check + (i32.const 2) ) (block (set_local $3 - (i32.const 0) - ) - (i32.const 2) - (block - (set_local $3 - (i32.const 2) - ) - (br $shape$1$continue) + (i32.const 2) ) + (br $shape$1$continue) ) ) ) @@ -731,7 +818,9 @@ raw: (func $return (type $i) (result i32) (local $0 i32) (block $the-list - (i32.const 42) + (call_import $check + (i32.const 42) + ) (return (i32.const 1337) ) @@ -742,22 +831,179 @@ optimized: (module (memory 0) (type $v (func)) + (type $vi (func (param i32))) (type $i (func (result i32))) + (import $check "module" "check" (param i32)) (func $just-one-block (type $v) - (nop) + (call_import $check + (i32.const 1337) + ) + ) + (func $two-blocks (type $v) + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + ) + (func $loop (type $v) + (loop $shape$0$continue + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (br $shape$0$continue) + ) + ) + (func $split (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + (call_import $check + (i32.const 2) + ) + ) + ) + (func $if (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + ) + (call_import $check + (i32.const 2) + ) + ) + (func $if-else (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + (call_import $check + (i32.const 2) + ) + ) + (call_import $check + (i32.const 3) + ) + ) + (func $loop-tail (type $v) + (loop $block$3$break $shape$0$continue + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (if + (i32.const 10) + (br $shape$0$continue) + (br $block$3$break) + ) + ) + (call_import $check + (i32.const 2) + ) + ) + (func $nontrivial-loop-plus-phi-to-head (type $v) + (call_import $check + (i32.const 0) + ) + (block $block$7$break + (loop $block$4$break $shape$1$continue + (call_import $check + (i32.const 1) + ) + (br_if $block$7$break + (i32.const 0) + ) + (call_import $check + (i32.const 2) + ) + (if + (i32.const -6) + (br $block$4$break) + (br $shape$1$continue) + ) + ) + (call_import $check + (i32.const 3) + ) + (if + (i32.const -10) + (call_import $check + (i32.const 4) + ) + ) + (call_import $check + (i32.const 5) + ) + ) + (call_import $check + (i32.const 6) + ) + ) + (func $switch (type $v) + (call_import $check + (i32.const 0) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$2 + (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default + (i32.const -99) + ) + ) + (call_import $check + (i32.const 1) + ) + (br $switch$1$leave) + ) + (call_import $check + (i32.const 2) + ) + (br $switch$1$leave) + ) + (call_import $check + (i32.const 3) + ) + ) ) (func $duffs-device (type $v) (local $0 i32) + (call_import $check + (i32.const 0) + ) (set_local $0 (i32.const 2) ) - (loop $shape$1$break $shape$1$continue + (loop $shape$1$continue (if (i32.eq (get_local $0) (i32.const 2) ) (block + (call_import $check + (i32.const 1) + ) (set_local $0 (i32.const 3) ) @@ -769,6 +1015,9 @@ optimized: (i32.const 3) ) (block + (call_import $check + (i32.const 2) + ) (set_local $0 (i32.const 2) ) @@ -779,6 +1028,9 @@ optimized: ) ) (func $return (type $i) (result i32) + (call_import $check + (i32.const 42) + ) (i32.const 1337) ) ) @@ -1517,303 +1769,503 @@ int main() { BinaryenIndex paramTypes[] = { 0 }; functionTypes[0] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } + { + BinaryenIndex paramTypes[] = { 1 }; + functionTypes[1] = BinaryenAddFunctionType(the_module, "vi", 0, paramTypes, 1); + } + BinaryenAddImport(the_module, "check", "module", "check", functionTypes[1]); the_relooper = RelooperCreate(); expressions[1] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[1]); - expressions[2] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { - BinaryenType varTypes[] = { 1 }; - functions[0] = BinaryenAddFunction(the_module, "just-one-block", functionTypes[0], varTypes, 1, expressions[2]); + BinaryenExpressionRef operands[] = { expressions[1] }; + expressions[2] = BinaryenCallImport(the_module, "check", operands, 1, 0); } - the_relooper = RelooperCreate(); - expressions[3] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[3]); - expressions[4] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[4]); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); - expressions[5] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[2]); + expressions[3] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[1] = BinaryenAddFunction(the_module, "two-blocks", functionTypes[0], varTypes, 1, expressions[5]); + functions[0] = BinaryenAddFunction(the_module, "just-one-block", functionTypes[0], varTypes, 1, expressions[3]); } the_relooper = RelooperCreate(); - expressions[6] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[6]); - expressions[7] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + expressions[4] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[4] }; + expressions[5] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[5]); + expressions[6] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[6] }; + expressions[7] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[7]); - expressions[8] = BinaryenConst(the_module, BinaryenLiteralInt32(77)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[8]); - expressions[9] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); + expressions[8] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[2] = BinaryenAddFunction(the_module, "two-blocks-plus-code", functionTypes[0], varTypes, 1, expressions[9]); + functions[1] = BinaryenAddFunction(the_module, "two-blocks", functionTypes[0], varTypes, 1, expressions[8]); } the_relooper = RelooperCreate(); - expressions[10] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + expressions[9] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[9] }; + expressions[10] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[10]); expressions[11] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[11]); + { + BinaryenExpressionRef operands[] = { expressions[11] }; + expressions[12] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[12]); + expressions[13] = BinaryenConst(the_module, BinaryenLiteralInt32(77)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[13]); + expressions[14] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + { + BinaryenType varTypes[] = { 1 }; + functions[2] = BinaryenAddFunction(the_module, "two-blocks-plus-code", functionTypes[0], varTypes, 1, expressions[14]); + } + the_relooper = RelooperCreate(); + expressions[15] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[15] }; + expressions[16] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[16]); + expressions[17] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[17] }; + expressions[18] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[18]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[0]); - expressions[12] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[19] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[3] = BinaryenAddFunction(the_module, "loop", functionTypes[0], varTypes, 1, expressions[12]); + functions[3] = BinaryenAddFunction(the_module, "loop", functionTypes[0], varTypes, 1, expressions[19]); } the_relooper = RelooperCreate(); - expressions[13] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[13]); - expressions[14] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[14]); - expressions[15] = BinaryenConst(the_module, BinaryenLiteralInt32(33)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[15]); - expressions[16] = BinaryenConst(the_module, BinaryenLiteralInt32(-66)); - RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[16]); - expressions[17] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[20] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[20] }; + expressions[21] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[21]); + expressions[22] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[22] }; + expressions[23] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[23]); + expressions[24] = BinaryenConst(the_module, BinaryenLiteralInt32(33)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[24]); + expressions[25] = BinaryenConst(the_module, BinaryenLiteralInt32(-66)); + RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[0], expressions[25]); + expressions[26] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[4] = BinaryenAddFunction(the_module, "loop-plus-code", functionTypes[0], varTypes, 1, expressions[17]); + functions[4] = BinaryenAddFunction(the_module, "loop-plus-code", functionTypes[0], varTypes, 1, expressions[26]); } the_relooper = RelooperCreate(); - expressions[18] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[18]); - expressions[19] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[19]); - expressions[20] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[20]); - expressions[21] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[21], expressions[0]); + expressions[27] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[27] }; + expressions[28] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[28]); + expressions[29] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[29] }; + expressions[30] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[30]); + expressions[31] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[31] }; + expressions[32] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[32]); + expressions[33] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[33], expressions[0]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[0]); - expressions[22] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[34] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[5] = BinaryenAddFunction(the_module, "split", functionTypes[0], varTypes, 1, expressions[22]); + functions[5] = BinaryenAddFunction(the_module, "split", functionTypes[0], varTypes, 1, expressions[34]); } the_relooper = RelooperCreate(); - expressions[23] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[23]); - expressions[24] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[24]); - expressions[25] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[25]); - expressions[26] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); - expressions[27] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[27], expressions[26]); - expressions[28] = BinaryenConst(the_module, BinaryenLiteralInt32(20)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[28]); - expressions[29] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[35] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[35] }; + expressions[36] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[36]); + expressions[37] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[37] }; + expressions[38] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[38]); + expressions[39] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[39] }; + expressions[40] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[40]); + expressions[41] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + expressions[42] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[42], expressions[41]); + expressions[43] = BinaryenConst(the_module, BinaryenLiteralInt32(20)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[43]); + expressions[44] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[6] = BinaryenAddFunction(the_module, "split-plus-code", functionTypes[0], varTypes, 1, expressions[29]); + functions[6] = BinaryenAddFunction(the_module, "split-plus-code", functionTypes[0], varTypes, 1, expressions[44]); } the_relooper = RelooperCreate(); - expressions[30] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[30]); - expressions[31] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[31]); - expressions[32] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[32]); - expressions[33] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[33], expressions[0]); + expressions[45] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[45] }; + expressions[46] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[46]); + expressions[47] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[47] }; + expressions[48] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[48]); + expressions[49] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[49] }; + expressions[50] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[50]); + expressions[51] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[51], expressions[0]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[0], expressions[0]); - expressions[34] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[52] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[7] = BinaryenAddFunction(the_module, "if", functionTypes[0], varTypes, 1, expressions[34]); + functions[7] = BinaryenAddFunction(the_module, "if", functionTypes[0], varTypes, 1, expressions[52]); } the_relooper = RelooperCreate(); - expressions[35] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[35]); - expressions[36] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[36]); - expressions[37] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[37]); - expressions[38] = BinaryenConst(the_module, BinaryenLiteralInt32(-1)); - expressions[39] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[39], expressions[38]); - expressions[40] = BinaryenConst(the_module, BinaryenLiteralInt32(-2)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[40]); - expressions[41] = BinaryenConst(the_module, BinaryenLiteralInt32(-3)); - RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[0], expressions[41]); - expressions[42] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[53] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[53] }; + expressions[54] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[54]); + expressions[55] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[55] }; + expressions[56] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[56]); + expressions[57] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[57] }; + expressions[58] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[58]); + expressions[59] = BinaryenConst(the_module, BinaryenLiteralInt32(-1)); + expressions[60] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[60], expressions[59]); + expressions[61] = BinaryenConst(the_module, BinaryenLiteralInt32(-2)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[61]); + expressions[62] = BinaryenConst(the_module, BinaryenLiteralInt32(-3)); + RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[0], expressions[62]); + expressions[63] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[8] = BinaryenAddFunction(the_module, "if-plus-code", functionTypes[0], varTypes, 1, expressions[42]); + functions[8] = BinaryenAddFunction(the_module, "if-plus-code", functionTypes[0], varTypes, 1, expressions[63]); } the_relooper = RelooperCreate(); - expressions[43] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[43]); - expressions[44] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[44]); - expressions[45] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[45]); - expressions[46] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[46]); - expressions[47] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[47], expressions[0]); + expressions[64] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[64] }; + expressions[65] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[65]); + expressions[66] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[66] }; + expressions[67] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[67]); + expressions[68] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[68] }; + expressions[69] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[69]); + expressions[70] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + { + BinaryenExpressionRef operands[] = { expressions[70] }; + expressions[71] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[71]); + expressions[72] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[72], expressions[0]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[3], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[2], relooperBlocks[3], expressions[0], expressions[0]); - expressions[48] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[73] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[9] = BinaryenAddFunction(the_module, "if-else", functionTypes[0], varTypes, 1, expressions[48]); + functions[9] = BinaryenAddFunction(the_module, "if-else", functionTypes[0], varTypes, 1, expressions[73]); } the_relooper = RelooperCreate(); - expressions[49] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[49]); - expressions[50] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[50]); - expressions[51] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[51]); + expressions[74] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[74] }; + expressions[75] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[75]); + expressions[76] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[76] }; + expressions[77] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[77]); + expressions[78] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[78] }; + expressions[79] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[79]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); - expressions[52] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); - RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[52], expressions[0]); + expressions[80] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + RelooperAddBranch(relooperBlocks[1], relooperBlocks[0], expressions[80], expressions[0]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[0], expressions[0]); - expressions[53] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[81] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[10] = BinaryenAddFunction(the_module, "loop-tail", functionTypes[0], varTypes, 1, expressions[53]); + functions[10] = BinaryenAddFunction(the_module, "loop-tail", functionTypes[0], varTypes, 1, expressions[81]); } the_relooper = RelooperCreate(); - expressions[54] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[54]); - expressions[55] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[55]); - expressions[56] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[56]); - expressions[57] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[57]); - expressions[58] = BinaryenConst(the_module, BinaryenLiteralInt32(4)); - relooperBlocks[4] = RelooperAddBlock(the_relooper, expressions[58]); - expressions[59] = BinaryenConst(the_module, BinaryenLiteralInt32(5)); - relooperBlocks[5] = RelooperAddBlock(the_relooper, expressions[59]); - expressions[60] = BinaryenConst(the_module, BinaryenLiteralInt32(6)); - relooperBlocks[6] = RelooperAddBlock(the_relooper, expressions[60]); - expressions[61] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[61]); - expressions[62] = BinaryenConst(the_module, BinaryenLiteralInt32(-2)); - RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[62], expressions[0]); - expressions[63] = BinaryenConst(the_module, BinaryenLiteralInt32(20)); - RelooperAddBranch(relooperBlocks[1], relooperBlocks[6], expressions[0], expressions[63]); - expressions[64] = BinaryenConst(the_module, BinaryenLiteralInt32(-6)); - RelooperAddBranch(relooperBlocks[2], relooperBlocks[3], expressions[64], expressions[0]); - expressions[65] = BinaryenConst(the_module, BinaryenLiteralInt32(30)); - RelooperAddBranch(relooperBlocks[2], relooperBlocks[1], expressions[0], expressions[65]); - expressions[66] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); - RelooperAddBranch(relooperBlocks[3], relooperBlocks[4], expressions[66], expressions[0]); + expressions[82] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[82] }; + expressions[83] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[83]); + expressions[84] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[84] }; + expressions[85] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[85]); + expressions[86] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[86] }; + expressions[87] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[87]); + expressions[88] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + { + BinaryenExpressionRef operands[] = { expressions[88] }; + expressions[89] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[89]); + expressions[90] = BinaryenConst(the_module, BinaryenLiteralInt32(4)); + { + BinaryenExpressionRef operands[] = { expressions[90] }; + expressions[91] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[4] = RelooperAddBlock(the_relooper, expressions[91]); + expressions[92] = BinaryenConst(the_module, BinaryenLiteralInt32(5)); + { + BinaryenExpressionRef operands[] = { expressions[92] }; + expressions[93] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[5] = RelooperAddBlock(the_relooper, expressions[93]); + expressions[94] = BinaryenConst(the_module, BinaryenLiteralInt32(6)); + { + BinaryenExpressionRef operands[] = { expressions[94] }; + expressions[95] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[6] = RelooperAddBlock(the_relooper, expressions[95]); + expressions[96] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[96]); + expressions[97] = BinaryenConst(the_module, BinaryenLiteralInt32(-2)); + RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[97], expressions[0]); + expressions[98] = BinaryenConst(the_module, BinaryenLiteralInt32(20)); + RelooperAddBranch(relooperBlocks[1], relooperBlocks[6], expressions[0], expressions[98]); + expressions[99] = BinaryenConst(the_module, BinaryenLiteralInt32(-6)); + RelooperAddBranch(relooperBlocks[2], relooperBlocks[3], expressions[99], expressions[0]); + expressions[100] = BinaryenConst(the_module, BinaryenLiteralInt32(30)); + RelooperAddBranch(relooperBlocks[2], relooperBlocks[1], expressions[0], expressions[100]); + expressions[101] = BinaryenConst(the_module, BinaryenLiteralInt32(-10)); + RelooperAddBranch(relooperBlocks[3], relooperBlocks[4], expressions[101], expressions[0]); RelooperAddBranch(relooperBlocks[3], relooperBlocks[5], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[4], relooperBlocks[5], expressions[0], expressions[0]); - expressions[67] = BinaryenConst(the_module, BinaryenLiteralInt32(40)); - RelooperAddBranch(relooperBlocks[5], relooperBlocks[6], expressions[0], expressions[67]); - expressions[68] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[102] = BinaryenConst(the_module, BinaryenLiteralInt32(40)); + RelooperAddBranch(relooperBlocks[5], relooperBlocks[6], expressions[0], expressions[102]); + expressions[103] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[11] = BinaryenAddFunction(the_module, "nontrivial-loop-plus-phi-to-head", functionTypes[0], varTypes, 1, expressions[68]); + functions[11] = BinaryenAddFunction(the_module, "nontrivial-loop-plus-phi-to-head", functionTypes[0], varTypes, 1, expressions[103]); } the_relooper = RelooperCreate(); - expressions[69] = BinaryenConst(the_module, BinaryenLiteralInt32(-99)); - expressions[70] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlockWithSwitch(the_relooper, expressions[70], expressions[69]); - expressions[71] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[71]); - expressions[72] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[72]); - expressions[73] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); - relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[73]); + expressions[104] = BinaryenConst(the_module, BinaryenLiteralInt32(-99)); + expressions[105] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[105] }; + expressions[106] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlockWithSwitch(the_relooper, expressions[106], expressions[104]); + expressions[107] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[107] }; + expressions[108] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[108]); + expressions[109] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[109] }; + expressions[110] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[110]); + expressions[111] = BinaryenConst(the_module, BinaryenLiteralInt32(3)); + { + BinaryenExpressionRef operands[] = { expressions[111] }; + expressions[112] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[112]); { BinaryenIndex indexes[] = { 2, 5 }; RelooperAddBranchForSwitch(relooperBlocks[0], relooperBlocks[1], indexes, 2, expressions[0]); } - expressions[74] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); + expressions[113] = BinaryenConst(the_module, BinaryenLiteralInt32(55)); { BinaryenIndex indexes[] = { 4 }; - RelooperAddBranchForSwitch(relooperBlocks[0], relooperBlocks[2], indexes, 1, expressions[74]); + RelooperAddBranchForSwitch(relooperBlocks[0], relooperBlocks[2], indexes, 1, expressions[113]); } { BinaryenIndex indexes[] = { 0 }; RelooperAddBranchForSwitch(relooperBlocks[0], relooperBlocks[3], indexes, 0, expressions[0]); } - expressions[75] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[114] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[12] = BinaryenAddFunction(the_module, "switch", functionTypes[0], varTypes, 1, expressions[75]); + functions[12] = BinaryenAddFunction(the_module, "switch", functionTypes[0], varTypes, 1, expressions[114]); } the_relooper = RelooperCreate(); - expressions[76] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[76]); - expressions[77] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); - relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[77]); - expressions[78] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); - relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[78]); - expressions[79] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); - RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[79], expressions[0]); + expressions[115] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); + { + BinaryenExpressionRef operands[] = { expressions[115] }; + expressions[116] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[116]); + expressions[117] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); + { + BinaryenExpressionRef operands[] = { expressions[117] }; + expressions[118] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[118]); + expressions[119] = BinaryenConst(the_module, BinaryenLiteralInt32(2)); + { + BinaryenExpressionRef operands[] = { expressions[119] }; + expressions[120] = BinaryenCallImport(the_module, "check", operands, 1, 0); + } + relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[120]); + expressions[121] = BinaryenConst(the_module, BinaryenLiteralInt32(10)); + RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[121], expressions[0]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[2], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[2], relooperBlocks[1], expressions[0], expressions[0]); - expressions[80] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 3, the_module); + expressions[122] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 3, the_module); { BinaryenType varTypes[] = { 1, 1, 2, 1, 3, 4, 1 }; - functions[13] = BinaryenAddFunction(the_module, "duffs-device", functionTypes[0], varTypes, 7, expressions[80]); + functions[13] = BinaryenAddFunction(the_module, "duffs-device", functionTypes[0], varTypes, 7, expressions[122]); } { BinaryenIndex paramTypes[] = { 0 }; - functionTypes[1] = BinaryenAddFunctionType(the_module, "i", 1, paramTypes, 0); + functionTypes[2] = BinaryenAddFunctionType(the_module, "i", 1, paramTypes, 0); } the_relooper = RelooperCreate(); - expressions[81] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); - expressions[82] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); - expressions[83] = BinaryenReturn(the_module, expressions[82]); + expressions[123] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); { - BinaryenExpressionRef children[] = { expressions[81], expressions[83] }; - expressions[84] = BinaryenBlock(the_module, "the-list", children, 2); + BinaryenExpressionRef operands[] = { expressions[123] }; + expressions[124] = BinaryenCallImport(the_module, "check", operands, 1, 0); } - relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[84]); - expressions[85] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); + expressions[125] = BinaryenConst(the_module, BinaryenLiteralInt32(1337)); + expressions[126] = BinaryenReturn(the_module, expressions[125]); + { + BinaryenExpressionRef children[] = { expressions[124], expressions[126] }; + expressions[127] = BinaryenBlock(the_module, "the-list", children, 2); + } + relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[127]); + expressions[128] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); { BinaryenType varTypes[] = { 1 }; - functions[14] = BinaryenAddFunction(the_module, "return", functionTypes[1], varTypes, 1, expressions[85]); + functions[14] = BinaryenAddFunction(the_module, "return", functionTypes[2], varTypes, 1, expressions[128]); } raw: BinaryenModulePrint(the_module); (module (memory 0) (type $v (func)) + (type $vi (func (param i32))) (type $i (func (result i32))) + (import $check "module" "check" (param i32)) (func $just-one-block (type $v) (local $0 i32) - (i32.const 1337) + (call_import $check + (i32.const 1337) + ) ) (func $two-blocks (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) ) ) (func $two-blocks-plus-code (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 77) + (br $block$2$break) ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) ) ) (func $loop (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) (block (br $shape$0$continue) ) @@ -1822,15 +2274,20 @@ raw: ) (func $loop-plus-code (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 33) + (br $block$2$break) ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) (block (i32.const -66) (br $shape$0$continue) @@ -1840,14 +2297,18 @@ raw: ) (func $split (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) ) - (block + ) + (block + (call_import $check (i32.const 2) ) ) @@ -1855,19 +2316,23 @@ raw: ) (func $split-plus-code (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (i32.const 10) (block - (i32.const 10) - (block + (call_import $check (i32.const 1) ) ) + ) + (block + (i32.const 20) (block - (i32.const 20) - (block + (call_import $check (i32.const 2) ) ) @@ -1876,166 +2341,197 @@ raw: ) (func $if (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (block $block$3$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) - (block - (br $shape$1$break) - ) + ) + (block + (br $block$3$break) ) ) + (br $block$3$break) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $if-plus-code (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) + (block $block$3$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (i32.const -1) (block - (i32.const -1) - (block + (call_import $check (i32.const 1) - (block - (i32.const -3) - (br $shape$1$break) - ) + ) + (block + (i32.const -3) + (br $block$3$break) ) ) + ) + (block (i32.const -2) + (br $block$3$break) ) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $if-else (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (block $block$4$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) - (block - (br $shape$1$break) - ) ) (block + (br $block$4$break) + ) + ) + (block + (call_import $check (i32.const 2) - (block - (br $shape$1$break) - ) + ) + (block + (br $block$4$break) ) ) ) ) (block - (i32.const 3) + (call_import $check + (i32.const 3) + ) ) ) (func $loop-tail (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) - ) - (block - (i32.const 1) - (if - (i32.const 10) - (br $shape$0$continue) - (br $shape$0$break) + (block $block$3$break + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) + ) + (block + (call_import $check + (i32.const 1) + ) + (if + (i32.const 10) + (br $shape$0$continue) + (br $block$3$break) + ) ) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $nontrivial-loop-plus-phi-to-head (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 10) + (br $block$2$break) ) ) (block - (loop $shape$1$break $shape$1$continue - (block - (i32.const 1) - (if - (i32.eqz - (i32.const -2) - ) - (block - (i32.const 20) - (br $shape$1$break) - ) - ) - ) - (block - (i32.const 2) - (if - (i32.const -6) - (block - (set_local $0 - (i32.const 4) + (block $block$7$break + (block $block$4$break + (loop $shape$1$continue + (block $block$3$break + (call_import $check + (i32.const 1) + ) + (if + (i32.const -2) + (br $block$3$break) + (block + (i32.const 20) + (br $block$7$break) + ) ) - (br $shape$1$break) ) (block - (i32.const 30) - (br $shape$1$continue) + (call_import $check + (i32.const 2) + ) + (if + (i32.const -6) + (br $block$4$break) + (block + (i32.const 30) + (br $shape$1$continue) + ) + ) ) ) ) - ) - (block - (block $shape$4$break - (if - (i32.eq - (get_local $0) - (i32.const 4) + (block + (block $block$6$break + (call_import $check + (i32.const 3) ) - (block + (if + (i32.const -10) (block - (i32.const 3) - (block $shape$6$break - (if - (i32.const -10) - (block - (i32.const 4) - (block - (br $shape$6$break) - ) - ) - ) + (call_import $check + (i32.const 4) ) - ) - (block - (i32.const 5) (block - (i32.const 40) - (br $shape$4$break) + (br $block$6$break) ) ) + (br $block$6$break) + ) + ) + (block + (call_import $check + (i32.const 5) + ) + (block + (i32.const 40) + (br $block$7$break) ) ) ) - (block + ) + (block + (call_import $check (i32.const 6) ) ) @@ -2043,38 +2539,44 @@ raw: ) (func $switch (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (block $switch$1$leave - (block $switch$1$default - (block $switch$1$case$3 - (block $switch$1$case$2 - (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default - (i32.const -99) - ) + (call_import $check + (i32.const 0) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$2 + (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default + (i32.const -99) ) + ) + (block (block - (block + (call_import $check (i32.const 1) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) + ) + (block + (i32.const 55) (block - (i32.const 55) - (block + (call_import $check (i32.const 2) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) + ) + (block (block - (block + (call_import $check (i32.const 3) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) ) ) (func $duffs-device (type $v) @@ -2086,52 +2588,66 @@ raw: (local $5 f64) (local $6 i32) (block - (i32.const 0) + (block $block$3$break + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 10) + (block + (set_local $3 + (i32.const 2) + ) + (br $block$2$break) + ) + (block + (set_local $3 + (i32.const 3) + ) + (br $block$3$break) + ) + ) + ) + ) + ) + (loop $shape$1$continue (if - (i32.const 10) - (set_local $3 + (i32.eq + (get_local $3) (i32.const 2) ) - (set_local $3 - (i32.const 3) + (block + (set_local $3 + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (block + (set_local $3 + (i32.const 3) + ) + (br $shape$1$continue) + ) ) - ) - ) - (loop $shape$1$break $shape$1$continue - (block $shape$2$break (if (i32.eq (get_local $3) - (i32.const 2) + (i32.const 3) ) (block (set_local $3 (i32.const 0) ) - (i32.const 1) - (block - (set_local $3 - (i32.const 3) - ) - (br $shape$1$continue) - ) - ) - (if - (i32.eq - (get_local $3) - (i32.const 3) + (call_import $check + (i32.const 2) ) (block (set_local $3 - (i32.const 0) - ) - (i32.const 2) - (block - (set_local $3 - (i32.const 2) - ) - (br $shape$1$continue) + (i32.const 2) ) + (br $shape$1$continue) ) ) ) @@ -2141,7 +2657,9 @@ raw: (func $return (type $i) (result i32) (local $0 i32) (block $the-list - (i32.const 42) + (call_import $check + (i32.const 42) + ) (return (i32.const 1337) ) @@ -2156,22 +2674,179 @@ optimized: (module (memory 0) (type $v (func)) + (type $vi (func (param i32))) (type $i (func (result i32))) + (import $check "module" "check" (param i32)) (func $just-one-block (type $v) - (nop) + (call_import $check + (i32.const 1337) + ) + ) + (func $two-blocks (type $v) + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + ) + (func $loop (type $v) + (loop $shape$0$continue + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (br $shape$0$continue) + ) + ) + (func $split (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + (call_import $check + (i32.const 2) + ) + ) + ) + (func $if (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + ) + (call_import $check + (i32.const 2) + ) + ) + (func $if-else (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + (call_import $check + (i32.const 2) + ) + ) + (call_import $check + (i32.const 3) + ) + ) + (func $loop-tail (type $v) + (loop $block$3$break $shape$0$continue + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (if + (i32.const 10) + (br $shape$0$continue) + (br $block$3$break) + ) + ) + (call_import $check + (i32.const 2) + ) + ) + (func $nontrivial-loop-plus-phi-to-head (type $v) + (call_import $check + (i32.const 0) + ) + (block $block$7$break + (loop $block$4$break $shape$1$continue + (call_import $check + (i32.const 1) + ) + (br_if $block$7$break + (i32.const 0) + ) + (call_import $check + (i32.const 2) + ) + (if + (i32.const -6) + (br $block$4$break) + (br $shape$1$continue) + ) + ) + (call_import $check + (i32.const 3) + ) + (if + (i32.const -10) + (call_import $check + (i32.const 4) + ) + ) + (call_import $check + (i32.const 5) + ) + ) + (call_import $check + (i32.const 6) + ) + ) + (func $switch (type $v) + (call_import $check + (i32.const 0) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$2 + (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default + (i32.const -99) + ) + ) + (call_import $check + (i32.const 1) + ) + (br $switch$1$leave) + ) + (call_import $check + (i32.const 2) + ) + (br $switch$1$leave) + ) + (call_import $check + (i32.const 3) + ) + ) ) (func $duffs-device (type $v) (local $0 i32) + (call_import $check + (i32.const 0) + ) (set_local $0 (i32.const 2) ) - (loop $shape$1$break $shape$1$continue + (loop $shape$1$continue (if (i32.eq (get_local $0) (i32.const 2) ) (block + (call_import $check + (i32.const 1) + ) (set_local $0 (i32.const 3) ) @@ -2183,6 +2858,9 @@ optimized: (i32.const 3) ) (block + (call_import $check + (i32.const 2) + ) (set_local $0 (i32.const 2) ) @@ -2193,6 +2871,9 @@ optimized: ) ) (func $return (type $i) (result i32) + (call_import $check + (i32.const 42) + ) (i32.const 1337) ) ) diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt index a9e599bef..96cbaaa00 100644 --- a/test/example/c-api-kitchen-sink.txt.txt +++ b/test/example/c-api-kitchen-sink.txt.txt @@ -364,40 +364,63 @@ (module (memory 0) (type $v (func)) + (type $vi (func (param i32))) (type $i (func (result i32))) + (import $check "module" "check" (param i32)) (func $just-one-block (type $v) (local $0 i32) - (i32.const 1337) + (call_import $check + (i32.const 1337) + ) ) (func $two-blocks (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) ) ) (func $two-blocks-plus-code (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 77) + (br $block$2$break) ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) ) ) (func $loop (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) (block (br $shape$0$continue) ) @@ -406,15 +429,20 @@ ) (func $loop-plus-code (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 33) + (br $block$2$break) ) ) (block - (i32.const 1) + (call_import $check + (i32.const 1) + ) (block (i32.const -66) (br $shape$0$continue) @@ -424,14 +452,18 @@ ) (func $split (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) ) - (block + ) + (block + (call_import $check (i32.const 2) ) ) @@ -439,19 +471,23 @@ ) (func $split-plus-code (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (i32.const 10) (block - (i32.const 10) - (block + (call_import $check (i32.const 1) ) ) + ) + (block + (i32.const 20) (block - (i32.const 20) - (block + (call_import $check (i32.const 2) ) ) @@ -460,166 +496,197 @@ ) (func $if (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (block $block$3$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) - (block - (br $shape$1$break) - ) + ) + (block + (br $block$3$break) ) ) + (br $block$3$break) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $if-plus-code (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) + (block $block$3$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (i32.const -1) (block - (i32.const -1) - (block + (call_import $check (i32.const 1) - (block - (i32.const -3) - (br $shape$1$break) - ) + ) + (block + (i32.const -3) + (br $block$3$break) ) ) + ) + (block (i32.const -2) + (br $block$3$break) ) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $if-else (type $v) (local $0 i32) - (block - (i32.const 0) - (block $shape$1$break - (if - (i32.const 55) - (block + (block $block$4$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (block + (call_import $check (i32.const 1) - (block - (br $shape$1$break) - ) ) (block + (br $block$4$break) + ) + ) + (block + (call_import $check (i32.const 2) - (block - (br $shape$1$break) - ) + ) + (block + (br $block$4$break) ) ) ) ) (block - (i32.const 3) + (call_import $check + (i32.const 3) + ) ) ) (func $loop-tail (type $v) (local $0 i32) - (loop $shape$0$break $shape$0$continue - (block - (i32.const 0) - ) - (block - (i32.const 1) - (if - (i32.const 10) - (br $shape$0$continue) - (br $shape$0$break) + (block $block$3$break + (loop $shape$0$continue + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (block + (br $block$2$break) + ) + ) + (block + (call_import $check + (i32.const 1) + ) + (if + (i32.const 10) + (br $shape$0$continue) + (br $block$3$break) + ) ) ) ) (block - (i32.const 2) + (call_import $check + (i32.const 2) + ) ) ) (func $nontrivial-loop-plus-phi-to-head (type $v) (local $0 i32) - (block - (i32.const 0) + (block $block$2$break + (call_import $check + (i32.const 0) + ) (block (i32.const 10) + (br $block$2$break) ) ) (block - (loop $shape$1$break $shape$1$continue - (block - (i32.const 1) - (if - (i32.eqz - (i32.const -2) - ) - (block - (i32.const 20) - (br $shape$1$break) - ) - ) - ) - (block - (i32.const 2) - (if - (i32.const -6) - (block - (set_local $0 - (i32.const 4) + (block $block$7$break + (block $block$4$break + (loop $shape$1$continue + (block $block$3$break + (call_import $check + (i32.const 1) + ) + (if + (i32.const -2) + (br $block$3$break) + (block + (i32.const 20) + (br $block$7$break) + ) ) - (br $shape$1$break) ) (block - (i32.const 30) - (br $shape$1$continue) + (call_import $check + (i32.const 2) + ) + (if + (i32.const -6) + (br $block$4$break) + (block + (i32.const 30) + (br $shape$1$continue) + ) + ) ) ) ) - ) - (block - (block $shape$4$break - (if - (i32.eq - (get_local $0) - (i32.const 4) + (block + (block $block$6$break + (call_import $check + (i32.const 3) ) - (block + (if + (i32.const -10) (block - (i32.const 3) - (block $shape$6$break - (if - (i32.const -10) - (block - (i32.const 4) - (block - (br $shape$6$break) - ) - ) - ) + (call_import $check + (i32.const 4) ) - ) - (block - (i32.const 5) (block - (i32.const 40) - (br $shape$4$break) + (br $block$6$break) ) ) + (br $block$6$break) + ) + ) + (block + (call_import $check + (i32.const 5) + ) + (block + (i32.const 40) + (br $block$7$break) ) ) ) - (block + ) + (block + (call_import $check (i32.const 6) ) ) @@ -627,38 +694,44 @@ ) (func $switch (type $v) (local $0 i32) - (i32.const 0) - (block $shape$1$break - (block $switch$1$leave - (block $switch$1$default - (block $switch$1$case$3 - (block $switch$1$case$2 - (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default - (i32.const -99) - ) + (call_import $check + (i32.const 0) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$2 + (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default + (i32.const -99) ) + ) + (block (block - (block + (call_import $check (i32.const 1) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) + ) + (block + (i32.const 55) (block - (i32.const 55) - (block + (call_import $check (i32.const 2) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) + ) + (block (block - (block + (call_import $check (i32.const 3) ) ) - (br $switch$1$leave) ) + (br $switch$1$leave) ) ) (func $duffs-device (type $v) @@ -670,52 +743,66 @@ (local $5 f64) (local $6 i32) (block - (i32.const 0) + (block $block$3$break + (block $block$2$break + (call_import $check + (i32.const 0) + ) + (if + (i32.const 10) + (block + (set_local $3 + (i32.const 2) + ) + (br $block$2$break) + ) + (block + (set_local $3 + (i32.const 3) + ) + (br $block$3$break) + ) + ) + ) + ) + ) + (loop $shape$1$continue (if - (i32.const 10) - (set_local $3 + (i32.eq + (get_local $3) (i32.const 2) ) - (set_local $3 - (i32.const 3) + (block + (set_local $3 + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (block + (set_local $3 + (i32.const 3) + ) + (br $shape$1$continue) + ) ) - ) - ) - (loop $shape$1$break $shape$1$continue - (block $shape$2$break (if (i32.eq (get_local $3) - (i32.const 2) + (i32.const 3) ) (block (set_local $3 (i32.const 0) ) - (i32.const 1) - (block - (set_local $3 - (i32.const 3) - ) - (br $shape$1$continue) - ) - ) - (if - (i32.eq - (get_local $3) - (i32.const 3) + (call_import $check + (i32.const 2) ) (block (set_local $3 - (i32.const 0) - ) - (i32.const 2) - (block - (set_local $3 - (i32.const 2) - ) - (br $shape$1$continue) + (i32.const 2) ) + (br $shape$1$continue) ) ) ) @@ -725,7 +812,9 @@ (func $return (type $i) (result i32) (local $0 i32) (block $the-list - (i32.const 42) + (call_import $check + (i32.const 42) + ) (return (i32.const 1337) ) @@ -735,22 +824,179 @@ (module (memory 0) (type $v (func)) + (type $vi (func (param i32))) (type $i (func (result i32))) + (import $check "module" "check" (param i32)) (func $just-one-block (type $v) - (nop) + (call_import $check + (i32.const 1337) + ) + ) + (func $two-blocks (type $v) + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + ) + (func $loop (type $v) + (loop $shape$0$continue + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (br $shape$0$continue) + ) + ) + (func $split (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + (call_import $check + (i32.const 2) + ) + ) + ) + (func $if (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + ) + (call_import $check + (i32.const 2) + ) + ) + (func $if-else (type $v) + (call_import $check + (i32.const 0) + ) + (if + (i32.const 55) + (call_import $check + (i32.const 1) + ) + (call_import $check + (i32.const 2) + ) + ) + (call_import $check + (i32.const 3) + ) + ) + (func $loop-tail (type $v) + (loop $block$3$break $shape$0$continue + (call_import $check + (i32.const 0) + ) + (call_import $check + (i32.const 1) + ) + (if + (i32.const 10) + (br $shape$0$continue) + (br $block$3$break) + ) + ) + (call_import $check + (i32.const 2) + ) + ) + (func $nontrivial-loop-plus-phi-to-head (type $v) + (call_import $check + (i32.const 0) + ) + (block $block$7$break + (loop $block$4$break $shape$1$continue + (call_import $check + (i32.const 1) + ) + (br_if $block$7$break + (i32.const 0) + ) + (call_import $check + (i32.const 2) + ) + (if + (i32.const -6) + (br $block$4$break) + (br $shape$1$continue) + ) + ) + (call_import $check + (i32.const 3) + ) + (if + (i32.const -10) + (call_import $check + (i32.const 4) + ) + ) + (call_import $check + (i32.const 5) + ) + ) + (call_import $check + (i32.const 6) + ) + ) + (func $switch (type $v) + (call_import $check + (i32.const 0) + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (block $switch$1$case$2 + (br_table $switch$1$default $switch$1$default $switch$1$case$2 $switch$1$default $switch$1$case$3 $switch$1$case$2 $switch$1$default + (i32.const -99) + ) + ) + (call_import $check + (i32.const 1) + ) + (br $switch$1$leave) + ) + (call_import $check + (i32.const 2) + ) + (br $switch$1$leave) + ) + (call_import $check + (i32.const 3) + ) + ) ) (func $duffs-device (type $v) (local $0 i32) + (call_import $check + (i32.const 0) + ) (set_local $0 (i32.const 2) ) - (loop $shape$1$break $shape$1$continue + (loop $shape$1$continue (if (i32.eq (get_local $0) (i32.const 2) ) (block + (call_import $check + (i32.const 1) + ) (set_local $0 (i32.const 3) ) @@ -762,6 +1008,9 @@ (i32.const 3) ) (block + (call_import $check + (i32.const 2) + ) (set_local $0 (i32.const 2) ) @@ -772,6 +1021,9 @@ ) ) (func $return (type $i) (result i32) + (call_import $check + (i32.const 42) + ) (i32.const 1337) ) ) diff --git a/test/example/relooper-fuzz.c b/test/example/relooper-fuzz.c index ecb204347..65d00aa5d 100644 --- a/test/example/relooper-fuzz.c +++ b/test/example/relooper-fuzz.c @@ -256,12 +256,14 @@ int main() { // memory BinaryenSetMemory(module, 1, 1, "mem", NULL, NULL, NULL, 0); + assert(BinaryenModuleValidate(module)); + + BinaryenModulePrint(module); + BinaryenModuleOptimize(module); assert(BinaryenModuleValidate(module)); - // write it out - BinaryenModulePrint(module); BinaryenModuleDispose(module); diff --git a/test/example/relooper-fuzz.txt b/test/example/relooper-fuzz.txt index 6a45dbe84..b4e6c8b57 100644 --- a/test/example/relooper-fuzz.txt +++ b/test/example/relooper-fuzz.txt @@ -152,6 +152,299 @@ (i32.const 112) (i32.const 34) ) + (block + (block + (block $block$6$break + (block $block$5$break + (block + (call_import $print + (i32.const 0) + ) + (set_local $0 + (call $check) + ) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 2) + ) + (i32.const 0) + ) + (block + (set_local $1 + (i32.const 6) + ) + (br $block$6$break) + ) + (block + (block + (call_import $print + (i32.const 8) + ) + (set_local $0 + (call $check) + ) + ) + (block + (br $block$5$break) + ) + ) + ) + ) + ) + ) + (loop $shape$3$continue + (block $block$5$break + (if + (i32.eq + (get_local $1) + (i32.const 6) + ) + (block + (set_local $1 + (i32.const 0) + ) + (block + (call_import $print + (i32.const 5) + ) + (set_local $0 + (call $check) + ) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 2) + ) + (i32.const 0) + ) + (br $shape$3$continue) + (block + (set_local $1 + (i32.const 6) + ) + (br $shape$3$continue) + ) + ) + ) + ) + ) + (block + (block $block$3$break + (block + (call_import $print + (i32.const 4) + ) + (set_local $0 + (call $check) + ) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 3) + ) + (i32.const 0) + ) + (br $shape$3$continue) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 3) + ) + (i32.const 1) + ) + (block + (set_local $1 + (i32.const 6) + ) + (br $shape$3$continue) + ) + (br $block$3$break) + ) + ) + ) + (block + (block + (call_import $print + (i32.const 2) + ) + (set_local $0 + (call $check) + ) + ) + (block + (set_local $1 + (i32.const 6) + ) + (br $shape$3$continue) + ) + ) + ) + ) + ) + ) +) +(module + (memory 1 1) + (export "mem" memory) + (start $main) + (type $i (func (result i32))) + (type $v (func)) + (type $vi (func (param i32))) + (import $print "spectest" "print" (param i32)) + (func $check (type $i) (result i32) + (if + (i32.eq + (i32.load + (i32.const 4) + ) + (i32.const 108) + ) + (unreachable) + ) + (i32.store + (i32.const 4) + (i32.add + (i32.load + (i32.const 4) + ) + (i32.const 4) + ) + ) + (call_import $print + (i32.sub + (i32.const 0) + (i32.load offset=4 + (i32.load + (i32.const 4) + ) + ) + ) + ) + (i32.load offset=4 + (i32.load + (i32.const 4) + ) + ) + ) + (func $main (type $v) + (local $0 i32) + (local $1 i32) + (i32.store + (i32.const 8) + (i32.const 89) + ) + (i32.store + (i32.const 12) + (i32.const 12) + ) + (i32.store + (i32.const 16) + (i32.const 78) + ) + (i32.store + (i32.const 20) + (i32.const 149) + ) + (i32.store + (i32.const 24) + (i32.const 118) + ) + (i32.store + (i32.const 28) + (i32.const 179) + ) + (i32.store + (i32.const 32) + (i32.const 127) + ) + (i32.store + (i32.const 36) + (i32.const 80) + ) + (i32.store + (i32.const 40) + (i32.const 21) + ) + (i32.store + (i32.const 44) + (i32.const 34) + ) + (i32.store + (i32.const 48) + (i32.const 119) + ) + (i32.store + (i32.const 52) + (i32.const 98) + ) + (i32.store + (i32.const 56) + (i32.const 38) + ) + (i32.store + (i32.const 60) + (i32.const 29) + ) + (i32.store + (i32.const 64) + (i32.const 36) + ) + (i32.store + (i32.const 68) + (i32.const 147) + ) + (i32.store + (i32.const 72) + (i32.const 13) + ) + (i32.store + (i32.const 76) + (i32.const 55) + ) + (i32.store + (i32.const 80) + (i32.const 166) + ) + (i32.store + (i32.const 84) + (i32.const 16) + ) + (i32.store + (i32.const 88) + (i32.const 143) + ) + (i32.store + (i32.const 92) + (i32.const 52) + ) + (i32.store + (i32.const 96) + (i32.const 130) + ) + (i32.store + (i32.const 100) + (i32.const 150) + ) + (i32.store + (i32.const 104) + (i32.const 176) + ) + (i32.store + (i32.const 108) + (i32.const 91) + ) + (i32.store + (i32.const 112) + (i32.const 34) + ) (call_import $print (i32.const 0) ) @@ -173,7 +466,7 @@ (call $check) ) ) - (loop $shape$3$break $shape$3$continue + (loop $shape$3$continue (if (i32.eq (get_local $0) diff --git a/test/example/relooper-fuzz1.c b/test/example/relooper-fuzz1.c new file mode 100644 index 000000000..fbbbfdd59 --- /dev/null +++ b/test/example/relooper-fuzz1.c @@ -0,0 +1,332 @@ + + +#include <assert.h> +#include <stdio.h> + +#include "binaryen-c.h" + +// globals: address 4 is index +// decisions are at address 8+ + +int main() { + BinaryenModuleRef module = BinaryenModuleCreate(); + + // check() + + // if the end, halt + BinaryenExpressionRef halter = BinaryenIf(module, + BinaryenBinary(module, + BinaryenEqInt32(), + BinaryenLoad(module, 4, 0, 0, 0, BinaryenInt32(), + BinaryenConst(module, BinaryenLiteralInt32(4))), + BinaryenConst(module, BinaryenLiteralInt32(4 * 30)) // jumps of 4 bytes + ), + BinaryenUnreachable(module), + NULL + ); + // increment index + BinaryenExpressionRef incer = BinaryenStore(module, + 4, 0, 0, + BinaryenConst(module, BinaryenLiteralInt32(4)), + BinaryenBinary(module, + BinaryenAddInt32(), + BinaryenLoad(module, 4, 0, 0, 0, BinaryenInt32(), + BinaryenConst(module, BinaryenLiteralInt32(4))), + BinaryenConst(module, BinaryenLiteralInt32(4)) + ) + ); + + // optionally, print the return value + BinaryenExpressionRef args[] = { + BinaryenBinary(module, + BinaryenSubInt32(), + BinaryenConst(module, BinaryenLiteralInt32(0)), + BinaryenLoad(module, + 4, 0, 4, 0, BinaryenInt32(), + BinaryenLoad(module, 4, 0, 0, 0, BinaryenInt32(), + BinaryenConst(module, BinaryenLiteralInt32(4))) + ) + ) + }; + BinaryenExpressionRef debugger; + if (1) debugger = BinaryenCallImport(module, "print", args, 1, + BinaryenNone()); + else debugger = BinaryenNop(module); + + // return the decision. need to subtract 4 that we just added, + // and add 8 since that's where we start, so overall offset 4 + BinaryenExpressionRef returner = BinaryenLoad(module, + 4, 0, 4, 0, BinaryenInt32(), + BinaryenLoad(module, 4, 0, 0, 0, BinaryenInt32(), + BinaryenConst(module, BinaryenLiteralInt32(4))) + ); + BinaryenExpressionRef checkBodyList[] = { halter, incer, debugger, + returner }; + BinaryenExpressionRef checkBody = BinaryenBlock(module, + NULL, checkBodyList, sizeof(checkBodyList) / sizeof(BinaryenExpressionRef) + ); + BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", + BinaryenInt32(), + NULL, 0); + BinaryenAddFunction(module, "check", i, NULL, 0, checkBody); + + // contents of main() begin here + + RelooperRef relooper = RelooperCreate(); + + + RelooperBlockRef b0; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(0)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b0 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b1; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(1)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b1 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b2; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(2)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b2 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b3; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(3)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b3 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b4; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(4)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b4 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b5; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(5)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b5 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b6; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(6)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b6 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b7; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(7)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b7 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b8; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(8)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b8 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperBlockRef b9; + { + BinaryenExpressionRef args[] = { + BinaryenConst(module, BinaryenLiteralInt32(9)) + }; + BinaryenExpressionRef list[] = { + BinaryenCallImport(module, "print", args, 1, BinaryenNone()), + BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, + BinaryenInt32())) + }; + + b9 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + + } + + RelooperAddBranch(b0, b2, BinaryenBinary(module, + BinaryenEqInt32(), + BinaryenBinary(module, + BinaryenRemUInt32(), + BinaryenGetLocal(module, 0, BinaryenInt32()), + BinaryenConst(module, BinaryenLiteralInt32(4)) + ), + BinaryenConst(module, BinaryenLiteralInt32(0)) + ), NULL); + + RelooperAddBranch(b0, b7, BinaryenBinary(module, + BinaryenEqInt32(), + BinaryenBinary(module, + BinaryenRemUInt32(), + BinaryenGetLocal(module, 0, BinaryenInt32()), + BinaryenConst(module, BinaryenLiteralInt32(4)) + ), + BinaryenConst(module, BinaryenLiteralInt32(2)) + ), NULL); + + RelooperAddBranch(b0, b3, NULL, NULL); + + RelooperAddBranch(b2, b3, BinaryenBinary(module, + BinaryenEqInt32(), + BinaryenBinary(module, + BinaryenRemUInt32(), + BinaryenGetLocal(module, 0, BinaryenInt32()), + BinaryenConst(module, BinaryenLiteralInt32(2)) + ), + BinaryenConst(module, BinaryenLiteralInt32(0)) + ), NULL); + + RelooperAddBranch(b2, b9, NULL, NULL); + + RelooperAddBranch(b3, b3, NULL, NULL); + + RelooperAddBranch(b7, b2, BinaryenBinary(module, + BinaryenEqInt32(), + BinaryenBinary(module, + BinaryenRemUInt32(), + BinaryenGetLocal(module, 0, BinaryenInt32()), + BinaryenConst(module, BinaryenLiteralInt32(3)) + ), + BinaryenConst(module, BinaryenLiteralInt32(0)) + ), NULL); + + RelooperAddBranch(b7, b9, NULL, NULL); + + BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, b0, 1, + module); + + int decisions[] = { 67, 131, 49, 36, 112, 161, 62, 166, 16, 88, 176, 152, 161, 194, 117, 180, 60, 166, 55, 183, 150, 73, 196, 143, 76, 182, 97, 140, 126, 3 }; + int numDecisions = sizeof(decisions)/sizeof(int); + + // write out all the decisions, then the body of the function + BinaryenExpressionRef full[numDecisions + 1]; + + { + int i; + for (i = 0; i < numDecisions; i++) { + full[i] = BinaryenStore(module, + 4, 0, 0, + BinaryenConst(module, BinaryenLiteralInt32(8 + 4 * i)), + BinaryenConst(module, BinaryenLiteralInt32(decisions[i])) + ); + } + } + full[numDecisions] = body; + BinaryenExpressionRef all = BinaryenBlock(module, NULL, full, + numDecisions + 1); + + BinaryenFunctionTypeRef v = BinaryenAddFunctionType(module, "v", + BinaryenNone(), + NULL, 0); + // locals: state, free-for-label + BinaryenType localTypes[] = { BinaryenInt32(), BinaryenInt32() }; + BinaryenFunctionRef theMain = BinaryenAddFunction(module, "main", v, + localTypes, 2, all); + BinaryenSetStart(module, theMain); + + // import + + BinaryenType iparams[] = { BinaryenInt32() }; + BinaryenFunctionTypeRef vi = BinaryenAddFunctionType(module, "vi", + BinaryenNone(), + iparams, 1); + BinaryenAddImport(module, "print", "spectest", "print", vi); + + // memory + BinaryenSetMemory(module, 1, 1, "mem", NULL, NULL, NULL, 0); + + assert(BinaryenModuleValidate(module)); + + BinaryenModulePrint(module); + + BinaryenModuleOptimize(module); + + assert(BinaryenModuleValidate(module)); + + BinaryenModulePrint(module); + + BinaryenModuleDispose(module); + + return 0; +} diff --git a/test/example/relooper-fuzz1.txt b/test/example/relooper-fuzz1.txt new file mode 100644 index 000000000..437dab062 --- /dev/null +++ b/test/example/relooper-fuzz1.txt @@ -0,0 +1,501 @@ +(module + (memory 1 1) + (export "mem" memory) + (start $main) + (type $i (func (result i32))) + (type $v (func)) + (type $vi (func (param i32))) + (import $print "spectest" "print" (param i32)) + (func $check (type $i) (result i32) + (if + (i32.eq + (i32.load + (i32.const 4) + ) + (i32.const 120) + ) + (unreachable) + ) + (i32.store + (i32.const 4) + (i32.add + (i32.load + (i32.const 4) + ) + (i32.const 4) + ) + ) + (call_import $print + (i32.sub + (i32.const 0) + (i32.load offset=4 + (i32.load + (i32.const 4) + ) + ) + ) + ) + (i32.load offset=4 + (i32.load + (i32.const 4) + ) + ) + ) + (func $main (type $v) + (local $0 i32) + (local $1 i32) + (i32.store + (i32.const 8) + (i32.const 67) + ) + (i32.store + (i32.const 12) + (i32.const 131) + ) + (i32.store + (i32.const 16) + (i32.const 49) + ) + (i32.store + (i32.const 20) + (i32.const 36) + ) + (i32.store + (i32.const 24) + (i32.const 112) + ) + (i32.store + (i32.const 28) + (i32.const 161) + ) + (i32.store + (i32.const 32) + (i32.const 62) + ) + (i32.store + (i32.const 36) + (i32.const 166) + ) + (i32.store + (i32.const 40) + (i32.const 16) + ) + (i32.store + (i32.const 44) + (i32.const 88) + ) + (i32.store + (i32.const 48) + (i32.const 176) + ) + (i32.store + (i32.const 52) + (i32.const 152) + ) + (i32.store + (i32.const 56) + (i32.const 161) + ) + (i32.store + (i32.const 60) + (i32.const 194) + ) + (i32.store + (i32.const 64) + (i32.const 117) + ) + (i32.store + (i32.const 68) + (i32.const 180) + ) + (i32.store + (i32.const 72) + (i32.const 60) + ) + (i32.store + (i32.const 76) + (i32.const 166) + ) + (i32.store + (i32.const 80) + (i32.const 55) + ) + (i32.store + (i32.const 84) + (i32.const 183) + ) + (i32.store + (i32.const 88) + (i32.const 150) + ) + (i32.store + (i32.const 92) + (i32.const 73) + ) + (i32.store + (i32.const 96) + (i32.const 196) + ) + (i32.store + (i32.const 100) + (i32.const 143) + ) + (i32.store + (i32.const 104) + (i32.const 76) + ) + (i32.store + (i32.const 108) + (i32.const 182) + ) + (i32.store + (i32.const 112) + (i32.const 97) + ) + (i32.store + (i32.const 116) + (i32.const 140) + ) + (i32.store + (i32.const 120) + (i32.const 126) + ) + (i32.store + (i32.const 124) + (i32.const 3) + ) + (block + (block $block$10$break + (block $block$4$break + (block $block$3$break + (block + (call_import $print + (i32.const 0) + ) + (set_local $0 + (call $check) + ) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 4) + ) + (i32.const 0) + ) + (br $block$3$break) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 4) + ) + (i32.const 2) + ) + (block + (block + (call_import $print + (i32.const 7) + ) + (set_local $0 + (call $check) + ) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 3) + ) + (i32.const 0) + ) + (br $block$3$break) + (br $block$10$break) + ) + ) + (br $block$4$break) + ) + ) + ) + (block + (block + (call_import $print + (i32.const 2) + ) + (set_local $0 + (call $check) + ) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 2) + ) + (i32.const 0) + ) + (br $block$4$break) + (br $block$10$break) + ) + ) + ) + (loop $shape$6$continue + (block + (call_import $print + (i32.const 3) + ) + (set_local $0 + (call $check) + ) + ) + (block + (br $shape$6$continue) + ) + ) + ) + (block + (block + (call_import $print + (i32.const 9) + ) + (set_local $0 + (call $check) + ) + ) + ) + ) + ) +) +(module + (memory 1 1) + (export "mem" memory) + (start $main) + (type $i (func (result i32))) + (type $v (func)) + (type $vi (func (param i32))) + (import $print "spectest" "print" (param i32)) + (func $check (type $i) (result i32) + (if + (i32.eq + (i32.load + (i32.const 4) + ) + (i32.const 120) + ) + (unreachable) + ) + (i32.store + (i32.const 4) + (i32.add + (i32.load + (i32.const 4) + ) + (i32.const 4) + ) + ) + (call_import $print + (i32.sub + (i32.const 0) + (i32.load offset=4 + (i32.load + (i32.const 4) + ) + ) + ) + ) + (i32.load offset=4 + (i32.load + (i32.const 4) + ) + ) + ) + (func $main (type $v) + (local $0 i32) + (i32.store + (i32.const 8) + (i32.const 67) + ) + (i32.store + (i32.const 12) + (i32.const 131) + ) + (i32.store + (i32.const 16) + (i32.const 49) + ) + (i32.store + (i32.const 20) + (i32.const 36) + ) + (i32.store + (i32.const 24) + (i32.const 112) + ) + (i32.store + (i32.const 28) + (i32.const 161) + ) + (i32.store + (i32.const 32) + (i32.const 62) + ) + (i32.store + (i32.const 36) + (i32.const 166) + ) + (i32.store + (i32.const 40) + (i32.const 16) + ) + (i32.store + (i32.const 44) + (i32.const 88) + ) + (i32.store + (i32.const 48) + (i32.const 176) + ) + (i32.store + (i32.const 52) + (i32.const 152) + ) + (i32.store + (i32.const 56) + (i32.const 161) + ) + (i32.store + (i32.const 60) + (i32.const 194) + ) + (i32.store + (i32.const 64) + (i32.const 117) + ) + (i32.store + (i32.const 68) + (i32.const 180) + ) + (i32.store + (i32.const 72) + (i32.const 60) + ) + (i32.store + (i32.const 76) + (i32.const 166) + ) + (i32.store + (i32.const 80) + (i32.const 55) + ) + (i32.store + (i32.const 84) + (i32.const 183) + ) + (i32.store + (i32.const 88) + (i32.const 150) + ) + (i32.store + (i32.const 92) + (i32.const 73) + ) + (i32.store + (i32.const 96) + (i32.const 196) + ) + (i32.store + (i32.const 100) + (i32.const 143) + ) + (i32.store + (i32.const 104) + (i32.const 76) + ) + (i32.store + (i32.const 108) + (i32.const 182) + ) + (i32.store + (i32.const 112) + (i32.const 97) + ) + (i32.store + (i32.const 116) + (i32.const 140) + ) + (i32.store + (i32.const 120) + (i32.const 126) + ) + (i32.store + (i32.const 124) + (i32.const 3) + ) + (block $block$10$break + (block $block$4$break + (call_import $print + (i32.const 0) + ) + (if + (i32.ne + (i32.rem_u + (set_local $0 + (call $check) + ) + (i32.const 4) + ) + (i32.const 0) + ) + (if + (i32.eq + (i32.rem_u + (get_local $0) + (i32.const 4) + ) + (i32.const 2) + ) + (block + (call_import $print + (i32.const 7) + ) + (br_if $block$10$break + (i32.ne + (i32.rem_u + (call $check) + (i32.const 3) + ) + (i32.const 0) + ) + ) + ) + (br $block$4$break) + ) + ) + (call_import $print + (i32.const 2) + ) + (br_if $block$10$break + (i32.ne + (i32.rem_u + (call $check) + (i32.const 2) + ) + (i32.const 0) + ) + ) + ) + (loop $shape$6$continue + (call_import $print + (i32.const 3) + ) + (call $check) + (br $shape$6$continue) + ) + ) + (call_import $print + (i32.const 9) + ) + (call $check) + ) +) |