diff options
-rwxr-xr-x | check.py | 35 | ||||
-rw-r--r-- | src/s2wasm.h | 82 | ||||
-rw-r--r-- | test/dot_s/basics.s | 23 | ||||
-rw-r--r-- | test/dot_s/basics.wast | 16 | ||||
-rw-r--r-- | test/dot_s/memops.s | 18 | ||||
-rw-r--r-- | test/dot_s/memops.wast | 12 | ||||
-rw-r--r-- | test/llvm_autogenerated/cfg-stackify.s | 333 | ||||
-rw-r--r-- | test/llvm_autogenerated/cfg-stackify.wast | 282 | ||||
-rw-r--r-- | test/llvm_autogenerated/dead-vreg.s | 20 | ||||
-rw-r--r-- | test/llvm_autogenerated/dead-vreg.wast | 16 | ||||
-rw-r--r-- | test/llvm_autogenerated/func.s | 5 | ||||
-rw-r--r-- | test/llvm_autogenerated/func.wast | 4 | ||||
-rw-r--r-- | test/llvm_autogenerated/phi.s | 11 | ||||
-rw-r--r-- | test/llvm_autogenerated/phi.wast | 8 | ||||
-rw-r--r-- | test/llvm_autogenerated/reg-stackify.s | 12 | ||||
-rw-r--r-- | test/llvm_autogenerated/reg-stackify.wast | 10 | ||||
-rw-r--r-- | test/llvm_autogenerated/store-results.s | 12 | ||||
-rw-r--r-- | test/llvm_autogenerated/store-results.wast | 8 | ||||
-rw-r--r-- | test/llvm_autogenerated/switch.s | 70 | ||||
-rw-r--r-- | test/llvm_autogenerated/switch.wast | 56 |
20 files changed, 581 insertions, 452 deletions
@@ -18,12 +18,15 @@ import os, shutil, sys, subprocess, difflib, json, time interpreter = None requested = [] +torture = True for arg in sys.argv[1:]: if arg.startswith('--interpreter='): interpreter = arg.split('=')[1] print '[ using wasm interpreter at "%s" ]' % interpreter assert os.path.exists(interpreter), 'interpreter not found' + elif arg == '--no-torture': + torture = False else: requested.append(arg) @@ -256,22 +259,24 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']: actual, err = proc.communicate() assert proc.returncode == 0, err -print '\n[ checking torture testcases... ]\n' - -import test.waterfall.src.link_assembly_files as link_assembly_files -s2wasm_torture_out = os.path.abspath(os.path.join('test', 's2wasm-torture-out')) -if os.path.isdir(s2wasm_torture_out): +if torture: + + print '\n[ checking torture testcases... ]\n' + + import test.waterfall.src.link_assembly_files as link_assembly_files + s2wasm_torture_out = os.path.abspath(os.path.join('test', 's2wasm-torture-out')) + if os.path.isdir(s2wasm_torture_out): + shutil.rmtree(s2wasm_torture_out) + os.mkdir(s2wasm_torture_out) + unexpected_result_count = link_assembly_files.run( + linker=os.path.abspath(os.path.join('bin', 's2wasm')), + files=os.path.abspath(os.path.join('test', 'torture-s', '*.s')), + fails=os.path.abspath(os.path.join('test', 's2wasm_known_gcc_test_failures.txt')), + out=s2wasm_torture_out) + assert os.path.isdir(s2wasm_torture_out), 'Expected output directory %s' % s2wasm_torture_out shutil.rmtree(s2wasm_torture_out) -os.mkdir(s2wasm_torture_out) -unexpected_result_count = link_assembly_files.run( - linker=os.path.abspath(os.path.join('bin', 's2wasm')), - files=os.path.abspath(os.path.join('test', 'torture-s', '*.s')), - fails=os.path.abspath(os.path.join('test', 's2wasm_known_gcc_test_failures.txt')), - out=s2wasm_torture_out) -assert os.path.isdir(s2wasm_torture_out), 'Expected output directory %s' % s2wasm_torture_out -shutil.rmtree(s2wasm_torture_out) -if unexpected_result_count: - fail(unexpected_result_count, 0) + if unexpected_result_count: + fail(unexpected_result_count, 0) print '\n[ checking example testcases... ]\n' diff --git a/src/s2wasm.h b/src/s2wasm.h index 9cb41b8d6..c192effc2 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -437,8 +437,15 @@ private: } // parse body func->body = allocator.alloc<Block>(); - std::vector<Block*> bstack; - bstack.push_back(func->body->dyn_cast<Block>()); + std::vector<Expression*> bstack; + auto addToBlock = [&bstack](Expression* curr) { + Expression* last = bstack.back(); + if (last->is<Loop>()) { + last = last->cast<Loop>()->body; + } + last->cast<Block>()->list.push_back(curr); + }; + bstack.push_back(func->body); std::vector<Expression*> estack; auto push = [&](Expression* curr) { //std::cerr << "push " << curr << '\n'; @@ -491,7 +498,7 @@ private: }; auto setOutput = [&](Expression* curr, Name assign) { if (assign.isNull() || assign.str[1] == 'd') { // discard - bstack.back()->list.push_back(curr); + addToBlock(curr); } else if (assign.str[1] == 'p') { // push push(curr); } else { // set to a local @@ -499,7 +506,7 @@ private: set->name = assign; set->value = curr; set->type = curr->type; - bstack.back()->list.push_back(set); + addToBlock(set); } }; auto makeBinary = [&](BinaryOp op, WasmType type) { @@ -774,10 +781,22 @@ private: default: abort_on("type.?"); } }; + // labels + size_t nextLabel = 0; + auto getNextLabel = [&nextLabel]() { + return cashew::IString(("label$" + std::to_string(nextLabel++)).c_str(), false); + }; + auto getBranchLabel = [&](uint32_t offset) { + assert(offset < bstack.size()); + Expression* target = bstack[bstack.size() - 1 - offset]; + if (target->is<Block>()) { + return target->cast<Block>()->name; + } else { + return target->cast<Loop>()->in; + } + }; // fixups std::vector<Block*> loopBlocks; // we need to clear their names - std::set<Name> seenLabels; // if we already used a label, we don't need it in a loop (there is a block above it, with that label) - Name lastLabel; // A loop has an 'in' label which appears before it. There might also be a block in between it and the loop, so we have to remember the last label // main loop while (1) { skipWhitespace(); @@ -792,38 +811,27 @@ private: handleTyped(f64); } else if (match("block")) { auto curr = allocator.alloc<Block>(); - curr->name = getStr(); - bstack.back()->list.push_back(curr); + curr->name = getNextLabel(); + addToBlock(curr); bstack.push_back(curr); - seenLabels.insert(curr->name); + } else if (match("end_block")) { + bstack.pop_back(); } else if (match(".LBB")) { - s -= 4; - lastLabel = getStrToColon(); - s++; - skipWhitespace(); - // pop all blocks/loops that reach this target - // pop all targets with this label - while (!bstack.empty()) { - auto curr = bstack.back(); - if (curr->name == lastLabel) { - bstack.pop_back(); - continue; - } - break; - } + s = strchr(s, '\n'); } else if (match("loop")) { auto curr = allocator.alloc<Loop>(); - bstack.back()->list.push_back(curr); - curr->in = lastLabel; - Name out = getStr(); - if (seenLabels.count(out) == 0) { - curr->out = out; - } + addToBlock(curr); + curr->in = getNextLabel(); + curr->out = getNextLabel(); auto block = allocator.alloc<Block>(); - block->name = out; // temporary, fake + block->name = curr->out; // temporary, fake - this way, on bstack we have the right label at the right offset for a br curr->body = block; loopBlocks.push_back(block); bstack.push_back(block); + bstack.push_back(curr); + } else if (match("end_loop")) { + bstack.pop_back(); + bstack.pop_back(); } else if (match("br")) { auto curr = allocator.alloc<Break>(); if (*s == '_') { @@ -831,8 +839,8 @@ private: curr->condition = getInput(); skipComma(); } - curr->name = getStr(); - bstack.back()->list.push_back(curr); + curr->name = getBranchLabel(getInt()); + addToBlock(curr); } else if (match("call")) { makeCall(none); } else if (match("copy_local")) { @@ -853,18 +861,18 @@ private: if (*s == '$') { curr->value = getInput(); } - bstack.back()->list.push_back(curr); + addToBlock(curr); } else if (match("tableswitch")) { auto curr = allocator.alloc<Switch>(); curr->value = getInput(); skipComma(); - curr->default_ = getCommaSeparated(); + curr->default_ = getBranchLabel(getInt()); while (skipComma()) { - curr->targets.push_back(getCommaSeparated()); + curr->targets.push_back(getBranchLabel(getInt())); } - bstack.back()->list.push_back(curr); + addToBlock(curr); } else if (match("unreachable")) { - bstack.back()->list.push_back(allocator.alloc<Unreachable>()); + addToBlock(allocator.alloc<Unreachable>()); } else if (match("memory_size")) { makeHost(MemorySize); } else if (match("grow_memory")) { diff --git a/test/dot_s/basics.s b/test/dot_s/basics.s index a37678ff7..a47765778 100644 --- a/test/dot_s/basics.s +++ b/test/dot_s/basics.s @@ -18,12 +18,12 @@ main: # @main i32.sub $push8=, $0, $pop7 i32.const $push9=, 1 i32.ne $push10=, $pop8, $pop9 - block .LBB0_5 - block .LBB0_4 - br_if $pop10, .LBB0_4 + block + block + br_if $pop10, 0 .LBB0_1: # %.preheader # =>This Inner Loop Header: Depth=1 - loop .LBB0_4 + loop i32.const $push12=, 10 i32.gt_s $push13=, $0, $pop12 i32.add $0=, $pop13, $0 @@ -31,24 +31,25 @@ main: # @main i32.rem_s $push15=, $0, $pop14 i32.const $push16=, 3 i32.ne $push17=, $pop15, $pop16 - block .LBB0_3 - br_if $pop17, .LBB0_3 + block + br_if $pop17, 0 # BB#2: # in Loop: Header=.LBB0_1 Depth=1 i32.const $push18=, 111 i32.rem_s $push19=, $0, $pop18 i32.add $0=, $pop19, $0 -.LBB0_3: # in Loop: Header=.LBB0_1 Depth=1 + end_block i32.const $push20=, 7 i32.rem_s $push21=, $0, $pop20 i32.const $push22=, 0 i32.eq $push23=, $pop21, $pop22 - br_if $pop23, .LBB0_5 - br .LBB0_1 -.LBB0_4: + br_if $pop23, 2 + br 0 + end_loop + end_block i32.const $push11=, -12 i32.add $0=, $0, $pop11 i32.const $discard=, main # just take address for testing -.LBB0_5: # %.loopexit + end_block return $0 .Lfunc_end0: .size main, .Lfunc_end0-main diff --git a/test/dot_s/basics.wast b/test/dot_s/basics.wast index b73f6c456..a81cfd8a9 100644 --- a/test/dot_s/basics.wast +++ b/test/dot_s/basics.wast @@ -10,8 +10,8 @@ (call_import $puts (i32.const 16) ) - (block $.LBB0_5 - (block $.LBB0_4 + (block $label$0 + (block $label$1 (br_if (i32.ne (i32.sub @@ -32,9 +32,9 @@ ) (i32.const 1) ) - $.LBB0_4 + $label$1 ) - (loop $.LBB0_1 + (loop $label$3 $label$2 (block (set_local $$0 (i32.add @@ -45,7 +45,7 @@ (get_local $$0) ) ) - (block $.LBB0_3 + (block $label$4 (br_if (i32.ne (i32.rem_s @@ -54,7 +54,7 @@ ) (i32.const 3) ) - $.LBB0_3 + $label$4 ) (set_local $$0 (i32.add @@ -74,9 +74,9 @@ ) (i32.const 0) ) - $.LBB0_5 + $label$1 ) - (br $.LBB0_1) + (br $label$2) ) ) ) diff --git a/test/dot_s/memops.s b/test/dot_s/memops.s index 64c967a13..aadab0db2 100644 --- a/test/dot_s/memops.s +++ b/test/dot_s/memops.s @@ -35,7 +35,7 @@ main: # @main copy_local $4=, $1 .LBB1_2: # Parent Loop .LBB1_1 Depth=1 # => This Inner Loop Header: Depth=2 - loop .LBB1_3 + loop i32.const $10=, 0 i32.add $10=, $12, $10 i32.add $push1=, $10, $4 @@ -46,11 +46,9 @@ main: # @main i32.const $3=, 1048576 i32.ne $push2=, $4, $3 copy_local $5=, $1 - br_if $pop2, .LBB1_2 -.LBB1_3: # %.preheader - # Parent Loop .LBB1_1 Depth=1 - # => This Inner Loop Header: Depth=2 - loop .LBB1_4 + br_if $pop2, 0 + end_loop + loop i32.const $11=, 0 i32.add $11=, $12, $11 i32.add $push3=, $11, $5 @@ -59,8 +57,8 @@ main: # @main i32.add $6=, $pop5, $6 i32.add $5=, $5, $2 i32.ne $push6=, $5, $3 - br_if $pop6, .LBB1_3 -.LBB1_4: # in Loop: Header=.LBB1_1 Depth=1 + br_if $pop6, 0 + end_loop i32.const $push7=, 3 i32.mul $push8=, $6, $pop7 i32.const $push9=, 5 @@ -73,8 +71,8 @@ main: # @main i32.add $0=, $0, $2 i32.const $push15=, 100 i32.ne $push16=, $0, $pop15 - br_if $pop16, .LBB1_1 -.LBB1_5: + br_if $pop16, 0 + end_loop call _Z6reporti@FUNCTION, $6 i32.const $push17=, 0 i32.const $9=, 1048576 diff --git a/test/dot_s/memops.wast b/test/dot_s/memops.wast index e8ea14590..5428d765b 100644 --- a/test/dot_s/memops.wast +++ b/test/dot_s/memops.wast @@ -69,12 +69,12 @@ (set_local $$6 (get_local $$1) ) - (loop $.LBB1_5 $.LBB1_1 + (loop $label$1 $label$0 (block (set_local $$4 (get_local $$1) ) - (loop $.LBB1_3 $.LBB1_2 + (loop $label$3 $label$2 (block (set_local $$10 (i32.const 0) @@ -115,11 +115,11 @@ (get_local $$4) (get_local $$3) ) - $.LBB1_2 + $label$2 ) ) ) - (loop $.LBB1_4 $.LBB1_3 + (loop $label$5 $label$4 (block (set_local $$11 (i32.const 0) @@ -155,7 +155,7 @@ (get_local $$5) (get_local $$3) ) - $.LBB1_3 + $label$4 ) ) ) @@ -188,7 +188,7 @@ (get_local $$0) (i32.const 100) ) - $.LBB1_1 + $label$0 ) ) ) diff --git a/test/llvm_autogenerated/cfg-stackify.s b/test/llvm_autogenerated/cfg-stackify.s index 121b7d55a..fcb9652d9 100644 --- a/test/llvm_autogenerated/cfg-stackify.s +++ b/test/llvm_autogenerated/cfg-stackify.s @@ -7,14 +7,15 @@ test0: .local i32 i32.const $1=, 0 .LBB0_1: - loop .LBB0_3 + loop i32.const $push0=, 1 i32.add $1=, $1, $pop0 i32.ge_s $push1=, $1, $0 - br_if $pop1, .LBB0_3 + br_if $pop1, 1 call something@FUNCTION - br .LBB0_1 + br 0 .LBB0_3: + end_loop return .Lfunc_end0: .size test0, .Lfunc_end0-test0 @@ -26,14 +27,15 @@ test1: .local i32 i32.const $1=, 0 .LBB1_1: - loop .LBB1_3 + loop i32.const $push0=, 1 i32.add $1=, $1, $pop0 i32.ge_s $push1=, $1, $0 - br_if $pop1, .LBB1_3 + br_if $pop1, 1 call something@FUNCTION - br .LBB1_1 + br 0 .LBB1_3: + end_loop return .Lfunc_end1: .size test1, .Lfunc_end1-test1 @@ -42,12 +44,12 @@ test1: .type test2,@function test2: .param i32, i32 - block .LBB2_2 + block i32.const $push0=, 1 i32.lt_s $push1=, $1, $pop0 - br_if $pop1, .LBB2_2 + br_if $pop1, 0 .LBB2_1: - loop .LBB2_2 + loop i32.const $push5=, -1 i32.add $1=, $1, $pop5 f64.load $push2=, 0($0) @@ -56,8 +58,10 @@ test2: f64.store $discard=, 0($0), $pop4 i32.const $push6=, 8 i32.add $0=, $0, $pop6 - br_if $1, .LBB2_1 + br_if $1, 0 .LBB2_2: + end_loop + end_block return .Lfunc_end2: .size test2, .Lfunc_end2-test2 @@ -68,26 +72,29 @@ doublediamond: .param i32, i32, i32 .result i32 .local i32 - block .LBB3_5 - block .LBB3_2 + block + block i32.const $push0=, 0 i32.store $3=, 0($2), $pop0 - br_if $0, .LBB3_2 + br_if $0, 0 i32.const $push4=, 1 i32.store $discard=, 0($2), $pop4 - br .LBB3_5 + br 1 .LBB3_2: - block .LBB3_4 + end_block + block i32.const $push1=, 2 i32.store $discard=, 0($2), $pop1 - br_if $1, .LBB3_4 + br_if $1, 0 i32.const $push3=, 3 i32.store $discard=, 0($2), $pop3 - br .LBB3_5 + br 1 .LBB3_4: + end_block i32.const $push2=, 4 i32.store $discard=, 0($2), $pop2 .LBB3_5: + end_block i32.const $push5=, 5 i32.store $discard=, 0($2), $pop5 return $3 @@ -100,13 +107,14 @@ triangle: .param i32, i32 .result i32 .local i32 - block .LBB4_2 + block i32.const $push0=, 0 i32.store $2=, 0($0), $pop0 - br_if $1, .LBB4_2 + br_if $1, 0 i32.const $push1=, 1 i32.store $discard=, 0($0), $pop1 .LBB4_2: + end_block i32.const $push2=, 2 i32.store $discard=, 0($0), $pop2 return $2 @@ -119,18 +127,20 @@ diamond: .param i32, i32 .result i32 .local i32 - block .LBB5_3 - block .LBB5_2 + block + block i32.const $push0=, 0 i32.store $2=, 0($0), $pop0 - br_if $1, .LBB5_2 + br_if $1, 0 i32.const $push2=, 1 i32.store $discard=, 0($0), $pop2 - br .LBB5_3 + br 1 .LBB5_2: + end_block i32.const $push1=, 2 i32.store $discard=, 0($0), $pop1 .LBB5_3: + end_block i32.const $push3=, 3 i32.store $discard=, 0($0), $pop3 return $2 @@ -156,11 +166,12 @@ minimal_loop: i32.const $push0=, 0 i32.store $discard=, 0($0), $pop0 .LBB7_1: - loop .LBB7_2 + loop i32.const $push1=, 1 i32.store $discard=, 0($0), $pop1 - br .LBB7_1 + br 0 .LBB7_2: + end_loop .Lfunc_end7: .size minimal_loop, .Lfunc_end7-minimal_loop @@ -173,13 +184,13 @@ simple_loop: i32.const $push0=, 0 i32.store $2=, 0($0), $pop0 .LBB8_1: - loop .LBB8_2 + loop i32.const $push1=, 1 i32.store $discard=, 0($0), $pop1 i32.const $push3=, 0 i32.eq $push4=, $1, $pop3 - br_if $pop4, .LBB8_1 -.LBB8_2: + br_if $pop4, 0 + end_loop i32.const $push2=, 2 i32.store $discard=, 0($0), $pop2 return $2 @@ -192,20 +203,22 @@ doubletriangle: .param i32, i32, i32 .result i32 .local i32 - block .LBB9_4 + block i32.const $push0=, 0 i32.store $3=, 0($2), $pop0 - br_if $0, .LBB9_4 - block .LBB9_3 + br_if $0, 0 + block i32.const $push1=, 2 i32.store $discard=, 0($2), $pop1 - br_if $1, .LBB9_3 + br_if $1, 0 i32.const $push2=, 3 i32.store $discard=, 0($2), $pop2 .LBB9_3: + end_block i32.const $push3=, 4 i32.store $discard=, 0($2), $pop3 .LBB9_4: + end_block i32.const $push4=, 5 i32.store $discard=, 0($2), $pop4 return $3 @@ -218,21 +231,23 @@ ifelse_earlyexits: .param i32, i32, i32 .result i32 .local i32 - block .LBB10_4 - block .LBB10_2 + block + block i32.const $push0=, 0 i32.store $3=, 0($2), $pop0 - br_if $0, .LBB10_2 + br_if $0, 0 i32.const $push3=, 1 i32.store $discard=, 0($2), $pop3 - br .LBB10_4 + br 1 .LBB10_2: + end_block i32.const $push1=, 2 i32.store $discard=, 0($2), $pop1 - br_if $1, .LBB10_4 + br_if $1, 0 i32.const $push2=, 3 i32.store $discard=, 0($2), $pop2 .LBB10_4: + end_block i32.const $push4=, 4 i32.store $discard=, 0($2), $pop4 return $3 @@ -245,31 +260,35 @@ doublediamond_in_a_loop: .param i32, i32, i32 .result i32 .LBB11_1: - loop .LBB11_7 - block .LBB11_6 - block .LBB11_3 + loop + block + block i32.const $push0=, 0 i32.store $discard=, 0($2), $pop0 - br_if $0, .LBB11_3 + br_if $0, 0 i32.const $push4=, 1 i32.store $discard=, 0($2), $pop4 - br .LBB11_6 + br 1 .LBB11_3: - block .LBB11_5 + end_block + block i32.const $push1=, 2 i32.store $discard=, 0($2), $pop1 - br_if $1, .LBB11_5 + br_if $1, 0 i32.const $push3=, 3 i32.store $discard=, 0($2), $pop3 - br .LBB11_6 + br 1 .LBB11_5: + end_block i32.const $push2=, 4 i32.store $discard=, 0($2), $pop2 .LBB11_6: + end_block i32.const $push5=, 5 i32.store $discard=, 0($2), $pop5 - br .LBB11_1 + br 0 .LBB11_7: + end_loop .Lfunc_end11: .size doublediamond_in_a_loop, .Lfunc_end11-doublediamond_in_a_loop @@ -277,22 +296,24 @@ doublediamond_in_a_loop: .type test3,@function test3: .param i32 - block .LBB12_5 + block i32.const $push0=, 0 - br_if $pop0, .LBB12_5 + br_if $pop0, 0 .LBB12_1: - loop .LBB12_4 - br_if $0, .LBB12_4 + loop + br_if $0, 1 .LBB12_2: - loop .LBB12_3 + loop i32.ne $push1=, $0, $0 - br_if $pop1, .LBB12_2 -.LBB12_3: + br_if $pop1, 0 + end_loop call bar@FUNCTION - br .LBB12_1 + br 0 .LBB12_4: + end_loop unreachable .LBB12_5: + end_block return .Lfunc_end12: .size test3, .Lfunc_end12-test3 @@ -301,32 +322,36 @@ test3: .type test4,@function test4: .param i32 - block .LBB13_8 - block .LBB13_7 - block .LBB13_4 + block + block + block i32.const $push0=, 3 i32.gt_s $push1=, $0, $pop0 - br_if $pop1, .LBB13_4 - block .LBB13_3 + br_if $pop1, 0 + block i32.const $push8=, 0 i32.eq $push9=, $0, $pop8 - br_if $pop9, .LBB13_3 + br_if $pop9, 0 i32.const $push6=, 2 i32.ne $push7=, $0, $pop6 - br_if $pop7, .LBB13_7 + br_if $pop7, 2 .LBB13_3: + end_block return .LBB13_4: + end_block i32.const $push2=, 4 i32.eq $push3=, $0, $pop2 - br_if $pop3, .LBB13_8 + br_if $pop3, 1 i32.const $push4=, 622 i32.ne $push5=, $0, $pop4 - br_if $pop5, .LBB13_7 + br_if $pop5, 0 return .LBB13_7: + end_block return .LBB13_8: + end_block return .Lfunc_end13: .size test4, .Lfunc_end13-test4 @@ -337,23 +362,24 @@ test5: .param i32, i32 .local i32, i32 .LBB14_1: - block .LBB14_4 - loop .LBB14_3 + block + loop i32.const $2=, 0 i32.store $3=, 0($2), $2 i32.const $2=, 1 i32.and $push0=, $0, $2 i32.const $push5=, 0 i32.eq $push6=, $pop0, $pop5 - br_if $pop6, .LBB14_4 + br_if $pop6, 2 i32.store $push2=, 0($3), $2 i32.and $push3=, $1, $pop2 - br_if $pop3, .LBB14_1 -.LBB14_3: + br_if $pop3, 0 + end_loop i32.const $push4=, 3 i32.store $discard=, 0($3), $pop4 return .LBB14_4: + end_block i32.const $push1=, 2 i32.store $discard=, 0($3), $pop1 return @@ -366,31 +392,33 @@ test6: .param i32, i32 .local i32, i32, i32 .LBB15_1: - block .LBB15_6 - block .LBB15_5 - loop .LBB15_4 + block + block + loop i32.const $2=, 0 i32.store $discard=, 0($2), $2 i32.const $3=, 1 i32.and $push0=, $0, $3 i32.const $push4=, 0 i32.eq $push5=, $pop0, $pop4 - br_if $pop5, .LBB15_6 + br_if $pop5, 3 i32.store $discard=, 0($2), $3 i32.and $4=, $1, $3 i32.const $push6=, 0 i32.eq $push7=, $4, $pop6 - br_if $pop7, .LBB15_5 + br_if $pop7, 2 i32.store $discard=, 0($2), $3 - br_if $4, .LBB15_1 -.LBB15_4: + br_if $4, 0 + end_loop i32.const $push3=, 2 i32.store $discard=, 0($2), $pop3 return .LBB15_5: + end_block i32.const $push1=, 3 i32.store $discard=, 0($2), $pop1 .LBB15_6: + end_block i32.const $push2=, 4 i32.store $discard=, 0($2), $pop2 return @@ -405,25 +433,26 @@ test7: i32.const $3=, 0 i32.store $2=, 0($3), $3 .LBB16_1: - loop .LBB16_5 - block .LBB16_4 + loop + block i32.const $push0=, 1 i32.store $3=, 0($2), $pop0 i32.and $push1=, $0, $3 - br_if $pop1, .LBB16_4 + br_if $pop1, 0 i32.const $push2=, 2 i32.store $discard=, 0($2), $pop2 i32.and $push3=, $1, $3 - br_if $pop3, .LBB16_1 + br_if $pop3, 1 i32.const $push4=, 4 i32.store $discard=, 0($2), $pop4 unreachable .LBB16_4: + end_block i32.const $push5=, 3 i32.store $discard=, 0($2), $pop5 i32.and $push6=, $1, $3 - br_if $pop6, .LBB16_1 -.LBB16_5: + br_if $pop6, 0 + end_loop i32.const $push7=, 5 i32.store $discard=, 0($2), $pop7 unreachable @@ -437,19 +466,22 @@ test8: .local i32 i32.const $0=, 0 .LBB17_1: - loop .LBB17_4 - block .LBB17_3 + loop + block i32.const $push0=, 0 i32.eq $push1=, $0, $pop0 - br_if $pop1, .LBB17_3 + br_if $pop1, 0 i32.const $push2=, 0 i32.eq $push3=, $0, $pop2 - br_if $pop3, .LBB17_1 + br_if $pop3, 1 .LBB17_3: - loop .LBB17_4 - br_if $0, .LBB17_3 - br .LBB17_1 + end_block + loop + br_if $0, 0 + br 2 .LBB17_4: + end_loop + end_loop .Lfunc_end17: .size test8, .Lfunc_end17-test8 @@ -460,38 +492,41 @@ test9: i32.const $1=, 0 i32.store $0=, 0($1), $1 .LBB18_1: - loop .LBB18_5 + loop i32.const $push0=, 1 i32.store $1=, 0($0), $pop0 i32.call $push1=, a@FUNCTION i32.and $push2=, $pop1, $1 i32.const $push13=, 0 i32.eq $push14=, $pop2, $pop13 - br_if $pop14, .LBB18_5 + br_if $pop14, 1 .LBB18_2: - loop .LBB18_5 - block .LBB18_4 + loop + block i32.const $push4=, 2 i32.store $discard=, 0($0), $pop4 i32.call $push5=, a@FUNCTION i32.and $push6=, $pop5, $1 i32.const $push15=, 0 i32.eq $push16=, $pop6, $pop15 - br_if $pop16, .LBB18_4 + br_if $pop16, 0 i32.const $push10=, 3 i32.store $discard=, 0($0), $pop10 i32.call $push11=, a@FUNCTION i32.and $push12=, $pop11, $1 - br_if $pop12, .LBB18_2 - br .LBB18_1 + br_if $pop12, 1 + br 3 .LBB18_4: + end_block i32.const $push7=, 4 i32.store $discard=, 0($0), $pop7 i32.call $push8=, a@FUNCTION i32.and $push9=, $pop8, $1 - br_if $pop9, .LBB18_2 - br .LBB18_1 + br_if $pop9, 0 + br 2 .LBB18_5: + end_loop + end_loop i32.const $push3=, 5 i32.store $discard=, 0($0), $pop3 return @@ -504,32 +539,36 @@ test10: .local i32, i32, i32, i32, i32 i32.const $0=, 2 .LBB19_1: - loop .LBB19_7 + loop copy_local $4=, $1 copy_local $3=, $0 i32.const $1=, 0 i32.const $0=, 3 i32.const $2=, 4 - br_if $4, .LBB19_1 + br_if $4, 0 .LBB19_2: - block .LBB19_6 - loop .LBB19_5 + block + loop copy_local $4=, $3 copy_local $3=, $2 .LBB19_3: - loop .LBB19_5 + loop copy_local $2=, $4 i32.const $push0=, 4 i32.gt_u $push1=, $2, $pop0 - br_if $pop1, .LBB19_1 + br_if $pop1, 5 copy_local $4=, $3 - tableswitch $2, .LBB19_3, .LBB19_3, .LBB19_5, .LBB19_1, .LBB19_2, .LBB19_6 + tableswitch $2, 0, 0, 1, 5, 2, 4 .LBB19_5: + end_loop + end_loop return .LBB19_6: + end_block i32.const $1=, 1 - br .LBB19_1 + br 0 .LBB19_7: + end_loop .Lfunc_end19: .size test10, .Lfunc_end19-test10 @@ -539,40 +578,45 @@ test11: .local i32 i32.const $0=, 0 i32.store $discard=, 0($0), $0 - block .LBB20_8 - block .LBB20_7 - block .LBB20_6 - block .LBB20_4 - br_if $0, .LBB20_4 - block .LBB20_3 + block + block + block + block + br_if $0, 0 + block i32.const $push4=, 1 i32.store $discard=, 0($0), $pop4 - br_if $0, .LBB20_3 + br_if $0, 0 i32.const $push5=, 2 i32.store $discard=, 0($0), $pop5 - br_if $0, .LBB20_6 + br_if $0, 2 .LBB20_3: + end_block i32.const $push7=, 3 i32.store $discard=, 0($0), $pop7 return .LBB20_4: + end_block i32.const $push0=, 4 i32.store $discard=, 0($0), $pop0 - br_if $0, .LBB20_8 + br_if $0, 2 i32.const $push1=, 5 i32.store $discard=, 0($0), $pop1 i32.const $push8=, 0 i32.eq $push9=, $0, $pop8 - br_if $pop9, .LBB20_7 + br_if $pop9, 1 .LBB20_6: + end_block i32.const $push6=, 7 i32.store $discard=, 0($0), $pop6 return .LBB20_7: + end_block i32.const $push2=, 6 i32.store $discard=, 0($0), $pop2 return .LBB20_8: + end_block i32.const $push3=, 8 i32.store $discard=, 0($0), $pop3 return @@ -585,35 +629,39 @@ test12: .param i32 .local i32 .LBB21_1: - loop .LBB21_8 + loop i32.load8_u $1=, 0($0) - block .LBB21_7 - block .LBB21_6 - block .LBB21_4 + block + block + block i32.const $push0=, 103 i32.gt_s $push1=, $1, $pop0 - br_if $pop1, .LBB21_4 + br_if $pop1, 0 i32.const $push6=, 42 i32.eq $push7=, $1, $pop6 - br_if $pop7, .LBB21_7 + br_if $pop7, 2 i32.const $push8=, 76 i32.eq $push9=, $1, $pop8 - br_if $pop9, .LBB21_7 - br .LBB21_6 + br_if $pop9, 2 + br 1 .LBB21_4: + end_block i32.const $push2=, 108 i32.eq $push3=, $1, $pop2 - br_if $pop3, .LBB21_7 + br_if $pop3, 1 i32.const $push4=, 104 i32.eq $push5=, $1, $pop4 - br_if $pop5, .LBB21_7 + br_if $pop5, 1 .LBB21_6: + end_block return .LBB21_7: + end_block i32.const $push10=, 1 i32.add $0=, $0, $pop10 - br .LBB21_1 + br 0 .LBB21_8: + end_loop .Lfunc_end21: .size test12, .Lfunc_end21-test12 @@ -621,28 +669,47 @@ test12: .type test13,@function test13: .local i32 - block .LBB22_2 + block i32.const $push0=, 0 i32.const $push3=, 0 i32.eq $push4=, $pop0, $pop3 - br_if $pop4, .LBB22_2 + br_if $pop4, 0 return .LBB22_2: + end_block i32.const $0=, 0 - block .LBB22_4 - br_if $0, .LBB22_4 + block + br_if $0, 0 i32.const $0=, 0 .LBB22_4: - block .LBB22_5 + end_block + block i32.const $push1=, 1 i32.and $push2=, $0, $pop1 i32.const $push5=, 0 i32.eq $push6=, $pop2, $pop5 - br_if $pop6, .LBB22_5 -.LBB22_5: + br_if $pop6, 0 + end_block unreachable .Lfunc_end22: .size test13, .Lfunc_end22-test13 + .globl test14 + .type test14,@function +test14: + .local i32 + i32.const $0=, 0 +.LBB23_1: + loop + br_if $0, 0 +.LBB23_2: + end_loop + loop + br_if $0, 0 + end_loop + return +.Lfunc_end23: + .size test14, .Lfunc_end23-test14 + .section ".note.GNU-stack","",@progbits diff --git a/test/llvm_autogenerated/cfg-stackify.wast b/test/llvm_autogenerated/cfg-stackify.wast index 3ee288461..f1a2ad63d 100644 --- a/test/llvm_autogenerated/cfg-stackify.wast +++ b/test/llvm_autogenerated/cfg-stackify.wast @@ -28,6 +28,7 @@ (export "test11" $test11) (export "test12" $test12) (export "test13" $test13) + (export "test14" $test14) (func $test0 (param $$0 i32) (local $$1 i32) (block $fake_return_waka123 @@ -35,7 +36,7 @@ (set_local $$1 (i32.const 0) ) - (loop $.LBB0_3 $.LBB0_1 + (loop $label$1 $label$0 (block (set_local $$1 (i32.add @@ -48,10 +49,10 @@ (get_local $$1) (get_local $$0) ) - $.LBB0_3 + $label$1 ) (call_import $something) - (br $.LBB0_1) + (br $label$0) ) ) (br $fake_return_waka123) @@ -65,7 +66,7 @@ (set_local $$1 (i32.const 0) ) - (loop $.LBB1_3 $.LBB1_1 + (loop $label$1 $label$0 (block (set_local $$1 (i32.add @@ -78,10 +79,10 @@ (get_local $$1) (get_local $$0) ) - $.LBB1_3 + $label$1 ) (call_import $something) - (br $.LBB1_1) + (br $label$0) ) ) (br $fake_return_waka123) @@ -91,15 +92,15 @@ (func $test2 (param $$0 i32) (param $$1 i32) (block $fake_return_waka123 (block - (block $.LBB2_2 + (block $label$0 (br_if (i32.lt_s (get_local $$1) (i32.const 1) ) - $.LBB2_2 + $label$0 ) - (loop $.LBB2_1 + (loop $label$2 $label$1 (block (set_local $$1 (i32.add @@ -124,7 +125,7 @@ ) (br_if (get_local $$1) - $.LBB2_1 + $label$1 ) ) ) @@ -137,8 +138,8 @@ (local $$3 i32) (block $fake_return_waka123 (block - (block $.LBB3_5 - (block $.LBB3_2 + (block $label$0 + (block $label$1 (set_local $$3 (i32.store align=4 (get_local $$2) @@ -147,28 +148,28 @@ ) (br_if (get_local $$0) - $.LBB3_2 + $label$1 ) (i32.store align=4 (get_local $$2) (i32.const 1) ) - (br $.LBB3_5) + (br $label$0) ) - (block $.LBB3_4 + (block $label$2 (i32.store align=4 (get_local $$2) (i32.const 2) ) (br_if (get_local $$1) - $.LBB3_4 + $label$2 ) (i32.store align=4 (get_local $$2) (i32.const 3) ) - (br $.LBB3_5) + (br $label$0) ) (i32.store align=4 (get_local $$2) @@ -189,7 +190,7 @@ (local $$2 i32) (block $fake_return_waka123 (block - (block $.LBB4_2 + (block $label$0 (set_local $$2 (i32.store align=4 (get_local $$0) @@ -198,7 +199,7 @@ ) (br_if (get_local $$1) - $.LBB4_2 + $label$0 ) (i32.store align=4 (get_local $$0) @@ -219,8 +220,8 @@ (local $$2 i32) (block $fake_return_waka123 (block - (block $.LBB5_3 - (block $.LBB5_2 + (block $label$0 + (block $label$1 (set_local $$2 (i32.store align=4 (get_local $$0) @@ -229,13 +230,13 @@ ) (br_if (get_local $$1) - $.LBB5_2 + $label$1 ) (i32.store align=4 (get_local $$0) (i32.const 1) ) - (br $.LBB5_3) + (br $label$0) ) (i32.store align=4 (get_local $$0) @@ -269,13 +270,13 @@ (get_local $$0) (i32.const 0) ) - (loop $.LBB7_2 $.LBB7_1 + (loop $label$1 $label$0 (block (i32.store align=4 (get_local $$0) (i32.const 1) ) - (br $.LBB7_1) + (br $label$0) ) ) ) @@ -289,7 +290,7 @@ (i32.const 0) ) ) - (loop $.LBB8_2 $.LBB8_1 + (loop $label$1 $label$0 (block (i32.store align=4 (get_local $$0) @@ -300,7 +301,7 @@ (get_local $$1) (i32.const 0) ) - $.LBB8_1 + $label$0 ) ) ) @@ -318,7 +319,7 @@ (local $$3 i32) (block $fake_return_waka123 (block - (block $.LBB9_4 + (block $label$0 (set_local $$3 (i32.store align=4 (get_local $$2) @@ -327,16 +328,16 @@ ) (br_if (get_local $$0) - $.LBB9_4 + $label$0 ) - (block $.LBB9_3 + (block $label$1 (i32.store align=4 (get_local $$2) (i32.const 2) ) (br_if (get_local $$1) - $.LBB9_3 + $label$1 ) (i32.store align=4 (get_local $$2) @@ -362,8 +363,8 @@ (local $$3 i32) (block $fake_return_waka123 (block - (block $.LBB10_4 - (block $.LBB10_2 + (block $label$0 + (block $label$1 (set_local $$3 (i32.store align=4 (get_local $$2) @@ -372,13 +373,13 @@ ) (br_if (get_local $$0) - $.LBB10_2 + $label$1 ) (i32.store align=4 (get_local $$2) (i32.const 1) ) - (br $.LBB10_4) + (br $label$0) ) (i32.store align=4 (get_local $$2) @@ -386,7 +387,7 @@ ) (br_if (get_local $$1) - $.LBB10_4 + $label$0 ) (i32.store align=4 (get_local $$2) @@ -404,38 +405,38 @@ ) ) (func $doublediamond_in_a_loop (param $$0 i32) (param $$1 i32) (param $$2 i32) (result i32) - (loop $.LBB11_7 $.LBB11_1 + (loop $label$1 $label$0 (block - (block $.LBB11_6 - (block $.LBB11_3 + (block $label$2 + (block $label$3 (i32.store align=4 (get_local $$2) (i32.const 0) ) (br_if (get_local $$0) - $.LBB11_3 + $label$3 ) (i32.store align=4 (get_local $$2) (i32.const 1) ) - (br $.LBB11_6) + (br $label$2) ) - (block $.LBB11_5 + (block $label$4 (i32.store align=4 (get_local $$2) (i32.const 2) ) (br_if (get_local $$1) - $.LBB11_5 + $label$4 ) (i32.store align=4 (get_local $$2) (i32.const 3) ) - (br $.LBB11_6) + (br $label$2) ) (i32.store align=4 (get_local $$2) @@ -446,37 +447,37 @@ (get_local $$2) (i32.const 5) ) - (br $.LBB11_1) + (br $label$0) ) ) ) (func $test3 (param $$0 i32) (block $fake_return_waka123 (block - (block $.LBB12_5 + (block $label$0 (br_if (i32.const 0) - $.LBB12_5 + $label$0 ) - (loop $.LBB12_4 $.LBB12_1 + (loop $label$2 $label$1 (block (br_if (get_local $$0) - $.LBB12_4 + $label$2 ) - (loop $.LBB12_3 $.LBB12_2 + (loop $label$4 $label$3 (block (br_if (i32.ne (get_local $$0) (get_local $$0) ) - $.LBB12_2 + $label$3 ) ) ) (call_import $bar) - (br $.LBB12_1) + (br $label$1) ) ) (unreachable) @@ -488,30 +489,30 @@ (func $test4 (param $$0 i32) (block $fake_return_waka123 (block - (block $.LBB13_8 - (block $.LBB13_7 - (block $.LBB13_4 + (block $label$0 + (block $label$1 + (block $label$2 (br_if (i32.gt_s (get_local $$0) (i32.const 3) ) - $.LBB13_4 + $label$2 ) - (block $.LBB13_3 + (block $label$3 (br_if (i32.eq (get_local $$0) (i32.const 0) ) - $.LBB13_3 + $label$3 ) (br_if (i32.ne (get_local $$0) (i32.const 2) ) - $.LBB13_7 + $label$1 ) ) (br $fake_return_waka123) @@ -521,14 +522,14 @@ (get_local $$0) (i32.const 4) ) - $.LBB13_8 + $label$0 ) (br_if (i32.ne (get_local $$0) (i32.const 622) ) - $.LBB13_7 + $label$1 ) (br $fake_return_waka123) ) @@ -543,8 +544,8 @@ (local $$3 i32) (block $fake_return_waka123 (block - (block $.LBB14_4 - (loop $.LBB14_3 $.LBB14_1 + (block $label$0 + (loop $label$2 $label$1 (block (set_local $$2 (i32.const 0) @@ -566,7 +567,7 @@ ) (i32.const 0) ) - $.LBB14_4 + $label$0 ) (br_if (i32.and @@ -576,7 +577,7 @@ (get_local $$2) ) ) - $.LBB14_1 + $label$1 ) ) ) @@ -600,9 +601,9 @@ (local $$4 i32) (block $fake_return_waka123 (block - (block $.LBB15_6 - (block $.LBB15_5 - (loop $.LBB15_4 $.LBB15_1 + (block $label$0 + (block $label$1 + (loop $label$3 $label$2 (block (set_local $$2 (i32.const 0) @@ -622,7 +623,7 @@ ) (i32.const 0) ) - $.LBB15_6 + $label$0 ) (i32.store align=4 (get_local $$2) @@ -639,7 +640,7 @@ (get_local $$4) (i32.const 0) ) - $.LBB15_5 + $label$1 ) (i32.store align=4 (get_local $$2) @@ -647,7 +648,7 @@ ) (br_if (get_local $$4) - $.LBB15_1 + $label$2 ) ) ) @@ -682,9 +683,9 @@ (get_local $$3) ) ) - (loop $.LBB16_5 $.LBB16_1 + (loop $label$1 $label$0 (block - (block $.LBB16_4 + (block $label$2 (set_local $$3 (i32.store align=4 (get_local $$2) @@ -696,7 +697,7 @@ (get_local $$0) (get_local $$3) ) - $.LBB16_4 + $label$2 ) (i32.store align=4 (get_local $$2) @@ -707,7 +708,7 @@ (get_local $$1) (get_local $$3) ) - $.LBB16_1 + $label$0 ) (i32.store align=4 (get_local $$2) @@ -724,7 +725,7 @@ (get_local $$1) (get_local $$3) ) - $.LBB16_1 + $label$0 ) ) ) @@ -739,31 +740,31 @@ (set_local $$0 (i32.const 0) ) - (loop $.LBB17_4 $.LBB17_1 + (loop $label$1 $label$0 (block - (block $.LBB17_3 + (block $label$2 (br_if (i32.eq (get_local $$0) (i32.const 0) ) - $.LBB17_3 + $label$2 ) (br_if (i32.eq (get_local $$0) (i32.const 0) ) - $.LBB17_1 + $label$0 ) ) - (loop $.LBB17_4 $.LBB17_3 + (loop $label$4 $label$3 (block (br_if (get_local $$0) - $.LBB17_3 + $label$3 ) - (br $.LBB17_1) + (br $label$0) ) ) ) @@ -783,7 +784,7 @@ (get_local $$1) ) ) - (loop $.LBB18_5 $.LBB18_1 + (loop $label$1 $label$0 (block (set_local $$1 (i32.store align=4 @@ -799,11 +800,11 @@ ) (i32.const 0) ) - $.LBB18_5 + $label$1 ) - (loop $.LBB18_5 $.LBB18_2 + (loop $label$3 $label$2 (block - (block $.LBB18_4 + (block $label$4 (i32.store align=4 (get_local $$0) (i32.const 2) @@ -816,7 +817,7 @@ ) (i32.const 0) ) - $.LBB18_4 + $label$4 ) (i32.store align=4 (get_local $$0) @@ -827,9 +828,9 @@ (call_import $a) (get_local $$1) ) - $.LBB18_2 + $label$2 ) - (br $.LBB18_1) + (br $label$0) ) (i32.store align=4 (get_local $$0) @@ -840,9 +841,9 @@ (call_import $a) (get_local $$1) ) - $.LBB18_2 + $label$2 ) - (br $.LBB18_1) + (br $label$0) ) ) ) @@ -866,7 +867,7 @@ (set_local $$0 (i32.const 2) ) - (loop $.LBB19_7 $.LBB19_1 + (loop $label$1 $label$0 (block (set_local $$4 (get_local $$1) @@ -885,10 +886,10 @@ ) (br_if (get_local $$4) - $.LBB19_1 + $label$0 ) - (block $.LBB19_6 - (loop $.LBB19_5 $.LBB19_2 + (block $label$2 + (loop $label$4 $label$3 (block (set_local $$4 (get_local $$3) @@ -896,7 +897,7 @@ (set_local $$3 (get_local $$2) ) - (loop $.LBB19_5 $.LBB19_3 + (loop $label$6 $label$5 (block (set_local $$2 (get_local $$4) @@ -906,14 +907,14 @@ (get_local $$2) (i32.const 4) ) - $.LBB19_1 + $label$0 ) (set_local $$4 (get_local $$3) ) (tableswitch (get_local $$2) - (table (br $.LBB19_3) (br $.LBB19_5) (br $.LBB19_1) (br $.LBB19_2) (br $.LBB19_6)) (br $.LBB19_3) + (table (br $label$5) (br $label$6) (br $label$0) (br $label$3) (br $label$2)) (br $label$5) ) ) ) @@ -924,7 +925,7 @@ (set_local $$1 (i32.const 1) ) - (br $.LBB19_1) + (br $label$0) ) ) ) @@ -941,22 +942,22 @@ (get_local $$0) (get_local $$0) ) - (block $.LBB20_8 - (block $.LBB20_7 - (block $.LBB20_6 - (block $.LBB20_4 + (block $label$0 + (block $label$1 + (block $label$2 + (block $label$3 (br_if (get_local $$0) - $.LBB20_4 + $label$3 ) - (block $.LBB20_3 + (block $label$4 (i32.store align=4 (get_local $$0) (i32.const 1) ) (br_if (get_local $$0) - $.LBB20_3 + $label$4 ) (i32.store align=4 (get_local $$0) @@ -964,7 +965,7 @@ ) (br_if (get_local $$0) - $.LBB20_6 + $label$2 ) ) (i32.store align=4 @@ -979,7 +980,7 @@ ) (br_if (get_local $$0) - $.LBB20_8 + $label$0 ) (i32.store align=4 (get_local $$0) @@ -990,7 +991,7 @@ (get_local $$0) (i32.const 0) ) - $.LBB20_7 + $label$1 ) ) (i32.store align=4 @@ -1017,52 +1018,52 @@ (local $$1 i32) (block $fake_return_waka123 (block - (loop $.LBB21_8 $.LBB21_1 + (loop $label$1 $label$0 (block (set_local $$1 (i32.load8_u align=1 (get_local $$0) ) ) - (block $.LBB21_7 - (block $.LBB21_6 - (block $.LBB21_4 + (block $label$2 + (block $label$3 + (block $label$4 (br_if (i32.gt_s (get_local $$1) (i32.const 103) ) - $.LBB21_4 + $label$4 ) (br_if (i32.eq (get_local $$1) (i32.const 42) ) - $.LBB21_7 + $label$2 ) (br_if (i32.eq (get_local $$1) (i32.const 76) ) - $.LBB21_7 + $label$2 ) - (br $.LBB21_6) + (br $label$3) ) (br_if (i32.eq (get_local $$1) (i32.const 108) ) - $.LBB21_7 + $label$2 ) (br_if (i32.eq (get_local $$1) (i32.const 104) ) - $.LBB21_7 + $label$2 ) ) (br $fake_return_waka123) @@ -1073,7 +1074,7 @@ (i32.const 1) ) ) - (br $.LBB21_1) + (br $label$0) ) ) ) @@ -1083,29 +1084,29 @@ (local $$0 i32) (block $fake_return_waka123 (block - (block $.LBB22_2 + (block $label$0 (br_if (i32.eq (i32.const 0) (i32.const 0) ) - $.LBB22_2 + $label$0 ) (br $fake_return_waka123) ) (set_local $$0 (i32.const 0) ) - (block $.LBB22_4 + (block $label$1 (br_if (get_local $$0) - $.LBB22_4 + $label$1 ) (set_local $$0 (i32.const 0) ) ) - (block $.LBB22_5 + (block $label$2 (br_if (i32.eq (i32.and @@ -1114,12 +1115,39 @@ ) (i32.const 0) ) - $.LBB22_5 + $label$2 ) ) (unreachable) ) ) ) + (func $test14 + (local $$0 i32) + (block $fake_return_waka123 + (block + (set_local $$0 + (i32.const 0) + ) + (loop $label$1 $label$0 + (block + (br_if + (get_local $$0) + $label$0 + ) + ) + ) + (loop $label$3 $label$2 + (block + (br_if + (get_local $$0) + $label$2 + ) + ) + ) + (br $fake_return_waka123) + ) + ) + ) ) ;; METADATA: { "asmConsts": {},"staticBump": 0 } diff --git a/test/llvm_autogenerated/dead-vreg.s b/test/llvm_autogenerated/dead-vreg.s index d6aa16575..83c484f36 100644 --- a/test/llvm_autogenerated/dead-vreg.s +++ b/test/llvm_autogenerated/dead-vreg.s @@ -6,36 +6,40 @@ foo: .param i32, i32, i32 .local i32, i32, i32, i32, i32, i32, i32 i32.const $4=, 1 - block .LBB0_5 + block i32.lt_s $push0=, $2, $4 - br_if $pop0, .LBB0_5 + br_if $pop0, 0 i32.const $5=, 0 i32.const $push1=, 2 i32.shl $3=, $1, $pop1 copy_local $6=, $5 .LBB0_2: - loop .LBB0_5 + loop copy_local $7=, $5 copy_local $8=, $0 copy_local $9=, $1 - block .LBB0_4 + block i32.lt_s $push2=, $1, $4 - br_if $pop2, .LBB0_4 + br_if $pop2, 0 .LBB0_3: - loop .LBB0_4 + loop i32.const $push3=, -1 i32.add $9=, $9, $pop3 i32.store $discard=, 0($8), $7 i32.const $push4=, 4 i32.add $8=, $8, $pop4 i32.add $7=, $7, $6 - br_if $9, .LBB0_3 + br_if $9, 0 .LBB0_4: + end_loop + end_block i32.add $6=, $6, $4 i32.add $0=, $0, $3 i32.ne $push5=, $6, $2 - br_if $pop5, .LBB0_2 + br_if $pop5, 0 .LBB0_5: + end_loop + end_block return .Lfunc_end0: .size foo, .Lfunc_end0-foo diff --git a/test/llvm_autogenerated/dead-vreg.wast b/test/llvm_autogenerated/dead-vreg.wast index 0ce06c41c..f99ee925a 100644 --- a/test/llvm_autogenerated/dead-vreg.wast +++ b/test/llvm_autogenerated/dead-vreg.wast @@ -14,13 +14,13 @@ (set_local $$4 (i32.const 1) ) - (block $.LBB0_5 + (block $label$0 (br_if (i32.lt_s (get_local $$2) (get_local $$4) ) - $.LBB0_5 + $label$0 ) (set_local $$5 (i32.const 0) @@ -34,7 +34,7 @@ (set_local $$6 (get_local $$5) ) - (loop $.LBB0_2 + (loop $label$2 $label$1 (block (set_local $$7 (get_local $$5) @@ -45,15 +45,15 @@ (set_local $$9 (get_local $$1) ) - (block $.LBB0_4 + (block $label$3 (br_if (i32.lt_s (get_local $$1) (get_local $$4) ) - $.LBB0_4 + $label$3 ) - (loop $.LBB0_3 + (loop $label$5 $label$4 (block (set_local $$9 (i32.add @@ -79,7 +79,7 @@ ) (br_if (get_local $$9) - $.LBB0_3 + $label$4 ) ) ) @@ -101,7 +101,7 @@ (get_local $$6) (get_local $$2) ) - $.LBB0_2 + $label$1 ) ) ) diff --git a/test/llvm_autogenerated/func.s b/test/llvm_autogenerated/func.s index 7bfa158f9..49425e63c 100644 --- a/test/llvm_autogenerated/func.s +++ b/test/llvm_autogenerated/func.s @@ -41,14 +41,15 @@ f4: .result i32 .local i32 i32.const $1=, 1 - block .LBB4_2 + block i32.and $push0=, $0, $1 i32.const $push2=, 0 i32.eq $push3=, $pop0, $pop2 - br_if $pop3, .LBB4_2 + br_if $pop3, 0 i32.const $push1=, 0 return $pop1 .LBB4_2: + end_block return $1 .Lfunc_end4: .size f4, .Lfunc_end4-f4 diff --git a/test/llvm_autogenerated/func.wast b/test/llvm_autogenerated/func.wast index 332c8880d..9523359bf 100644 --- a/test/llvm_autogenerated/func.wast +++ b/test/llvm_autogenerated/func.wast @@ -45,7 +45,7 @@ (set_local $$1 (i32.const 1) ) - (block $.LBB4_2 + (block $label$0 (br_if (i32.eq (i32.and @@ -54,7 +54,7 @@ ) (i32.const 0) ) - $.LBB4_2 + $label$0 ) (br $fake_return_waka123 (i32.const 0) diff --git a/test/llvm_autogenerated/phi.s b/test/llvm_autogenerated/phi.s index d16bd75ac..b29451aaf 100644 --- a/test/llvm_autogenerated/phi.s +++ b/test/llvm_autogenerated/phi.s @@ -5,13 +5,14 @@ test0: .param i32 .result i32 - block .LBB0_2 + block i32.const $push0=, -1 i32.gt_s $push1=, $0, $pop0 - br_if $pop1, .LBB0_2 + br_if $pop1, 0 i32.const $push2=, 3 i32.div_s $0=, $0, $pop2 .LBB0_2: + end_block return $0 .Lfunc_end0: .size test0, .Lfunc_end0-test0 @@ -27,14 +28,14 @@ test1: copy_local $4=, $2 copy_local $5=, $3 .LBB1_1: - loop .LBB1_2 + loop copy_local $1=, $4 copy_local $4=, $3 i32.add $5=, $5, $2 copy_local $3=, $1 i32.lt_s $push0=, $5, $0 - br_if $pop0, .LBB1_1 -.LBB1_2: + br_if $pop0, 0 + end_loop return $4 .Lfunc_end1: .size test1, .Lfunc_end1-test1 diff --git a/test/llvm_autogenerated/phi.wast b/test/llvm_autogenerated/phi.wast index 87b681a04..301f1a670 100644 --- a/test/llvm_autogenerated/phi.wast +++ b/test/llvm_autogenerated/phi.wast @@ -5,13 +5,13 @@ (func $test0 (param $$0 i32) (result i32) (block $fake_return_waka123 (block - (block $.LBB0_2 + (block $label$0 (br_if (i32.gt_s (get_local $$0) (i32.const -1) ) - $.LBB0_2 + $label$0 ) (set_local $$0 (i32.div_s @@ -46,7 +46,7 @@ (set_local $$5 (get_local $$3) ) - (loop $.LBB1_2 $.LBB1_1 + (loop $label$1 $label$0 (block (set_local $$1 (get_local $$4) @@ -68,7 +68,7 @@ (get_local $$5) (get_local $$0) ) - $.LBB1_1 + $label$0 ) ) ) diff --git a/test/llvm_autogenerated/reg-stackify.s b/test/llvm_autogenerated/reg-stackify.s index 5c684e423..1fffec602 100644 --- a/test/llvm_autogenerated/reg-stackify.s +++ b/test/llvm_autogenerated/reg-stackify.s @@ -54,7 +54,7 @@ stack_uses: .local i32, i32 i32.const $5=, 2 i32.const $4=, 1 - block .LBB4_2 + block i32.lt_s $push0=, $0, $4 i32.lt_s $push1=, $1, $5 i32.xor $push4=, $pop0, $pop1 @@ -63,10 +63,11 @@ stack_uses: i32.xor $push5=, $pop2, $pop3 i32.xor $push6=, $pop4, $pop5 i32.ne $push7=, $pop6, $4 - br_if $pop7, .LBB4_2 + br_if $pop7, 0 i32.const $push8=, 0 return $pop8 .LBB4_2: + end_block return $4 .Lfunc_end4: .size stack_uses, .Lfunc_end4-stack_uses @@ -77,13 +78,14 @@ multiple_uses: .param i32, i32, i32 .local i32 i32.load $3=, 0($2) - block .LBB5_3 + block i32.ge_u $push0=, $3, $1 - br_if $pop0, .LBB5_3 + br_if $pop0, 0 i32.lt_u $push1=, $3, $0 - br_if $pop1, .LBB5_3 + br_if $pop1, 0 i32.store $discard=, 0($2), $3 .LBB5_3: + end_block return .Lfunc_end5: .size multiple_uses, .Lfunc_end5-multiple_uses diff --git a/test/llvm_autogenerated/reg-stackify.wast b/test/llvm_autogenerated/reg-stackify.wast index 60592413c..75dc7291e 100644 --- a/test/llvm_autogenerated/reg-stackify.wast +++ b/test/llvm_autogenerated/reg-stackify.wast @@ -79,7 +79,7 @@ (set_local $$4 (i32.const 1) ) - (block $.LBB4_2 + (block $label$0 (br_if (i32.ne (i32.xor @@ -106,7 +106,7 @@ ) (get_local $$4) ) - $.LBB4_2 + $label$0 ) (br $fake_return_waka123 (i32.const 0) @@ -127,20 +127,20 @@ (get_local $$2) ) ) - (block $.LBB5_3 + (block $label$0 (br_if (i32.ge_u (get_local $$3) (get_local $$1) ) - $.LBB5_3 + $label$0 ) (br_if (i32.lt_u (get_local $$3) (get_local $$0) ) - $.LBB5_3 + $label$0 ) (i32.store align=4 (get_local $$2) diff --git a/test/llvm_autogenerated/store-results.s b/test/llvm_autogenerated/store-results.s index 6356d5d92..f574cf7a7 100644 --- a/test/llvm_autogenerated/store-results.s +++ b/test/llvm_autogenerated/store-results.s @@ -18,14 +18,14 @@ foo: i32.const $0=, 0 copy_local $1=, $0 .LBB1_1: - loop .LBB1_2 + loop i32.const $push0=, 1 i32.add $1=, $1, $pop0 i32.store $discard=, pos($0), $0 i32.const $push1=, 256 i32.ne $push2=, $1, $pop1 - br_if $pop2, .LBB1_1 -.LBB1_2: + br_if $pop2, 0 + end_loop return .Lfunc_end1: .size foo, .Lfunc_end1-foo @@ -37,14 +37,14 @@ bar: f32.const $1=, 0x0p0 i32.const $0=, 0 .LBB2_1: - loop .LBB2_2 + loop i32.store $discard=, pos($0), $0 f32.const $push0=, 0x1p0 f32.add $1=, $1, $pop0 f32.const $push1=, 0x1p8 f32.ne $push2=, $1, $pop1 - br_if $pop2, .LBB2_1 -.LBB2_2: + br_if $pop2, 0 + end_loop return .Lfunc_end2: .size bar, .Lfunc_end2-bar diff --git a/test/llvm_autogenerated/store-results.wast b/test/llvm_autogenerated/store-results.wast index 36d9a03e3..34639a9d1 100644 --- a/test/llvm_autogenerated/store-results.wast +++ b/test/llvm_autogenerated/store-results.wast @@ -26,7 +26,7 @@ (set_local $$1 (get_local $$0) ) - (loop $.LBB1_2 $.LBB1_1 + (loop $label$1 $label$0 (block (set_local $$1 (i32.add @@ -43,7 +43,7 @@ (get_local $$1) (i32.const 256) ) - $.LBB1_1 + $label$0 ) ) ) @@ -62,7 +62,7 @@ (set_local $$0 (i32.const 0) ) - (loop $.LBB2_2 $.LBB2_1 + (loop $label$1 $label$0 (block (i32.store offset=4 align=4 (get_local $$0) @@ -79,7 +79,7 @@ (get_local $$1) (f32.const 256) ) - $.LBB2_1 + $label$0 ) ) ) diff --git a/test/llvm_autogenerated/switch.s b/test/llvm_autogenerated/switch.s index 35fda0849..d64cfd92b 100644 --- a/test/llvm_autogenerated/switch.s +++ b/test/llvm_autogenerated/switch.s @@ -4,35 +4,42 @@ .type bar32,@function bar32: .param i32 - block .LBB0_8 + block i32.const $push0=, 23 i32.gt_u $push1=, $0, $pop0 - br_if $pop1, .LBB0_8 - block .LBB0_7 - block .LBB0_6 - block .LBB0_5 - block .LBB0_4 - block .LBB0_3 - block .LBB0_2 - tableswitch $0, .LBB0_2, .LBB0_2, .LBB0_2, .LBB0_2, .LBB0_2, .LBB0_2, .LBB0_2, .LBB0_2, .LBB0_3, .LBB0_3, .LBB0_3, .LBB0_3, .LBB0_3, .LBB0_3, .LBB0_3, .LBB0_3, .LBB0_4, .LBB0_4, .LBB0_4, .LBB0_4, .LBB0_4, .LBB0_4, .LBB0_5, .LBB0_6, .LBB0_7 + br_if $pop1, 0 + block + block + block + block + block + block + tableswitch $0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5 .LBB0_2: + end_block call foo0@FUNCTION - br .LBB0_8 + br 5 .LBB0_3: + end_block call foo1@FUNCTION - br .LBB0_8 + br 4 .LBB0_4: + end_block call foo2@FUNCTION - br .LBB0_8 + br 3 .LBB0_5: + end_block call foo3@FUNCTION - br .LBB0_8 + br 2 .LBB0_6: + end_block call foo4@FUNCTION - br .LBB0_8 + br 1 .LBB0_7: + end_block call foo5@FUNCTION .LBB0_8: + end_block return .Lfunc_end0: .size bar32, .Lfunc_end0-bar32 @@ -41,36 +48,43 @@ bar32: .type bar64,@function bar64: .param i64 - block .LBB1_8 + block i64.const $push1=, 23 i64.gt_u $push2=, $0, $pop1 - br_if $pop2, .LBB1_8 - block .LBB1_7 - block .LBB1_6 - block .LBB1_5 - block .LBB1_4 - block .LBB1_3 - block .LBB1_2 + br_if $pop2, 0 + block + block + block + block + block + block i32.wrap/i64 $push0=, $0 - tableswitch $pop0, .LBB1_2, .LBB1_2, .LBB1_2, .LBB1_2, .LBB1_2, .LBB1_2, .LBB1_2, .LBB1_2, .LBB1_3, .LBB1_3, .LBB1_3, .LBB1_3, .LBB1_3, .LBB1_3, .LBB1_3, .LBB1_3, .LBB1_4, .LBB1_4, .LBB1_4, .LBB1_4, .LBB1_4, .LBB1_4, .LBB1_5, .LBB1_6, .LBB1_7 + tableswitch $pop0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5 .LBB1_2: + end_block call foo0@FUNCTION - br .LBB1_8 + br 5 .LBB1_3: + end_block call foo1@FUNCTION - br .LBB1_8 + br 4 .LBB1_4: + end_block call foo2@FUNCTION - br .LBB1_8 + br 3 .LBB1_5: + end_block call foo3@FUNCTION - br .LBB1_8 + br 2 .LBB1_6: + end_block call foo4@FUNCTION - br .LBB1_8 + br 1 .LBB1_7: + end_block call foo5@FUNCTION .LBB1_8: + end_block return .Lfunc_end1: .size bar64, .Lfunc_end1-bar64 diff --git a/test/llvm_autogenerated/switch.wast b/test/llvm_autogenerated/switch.wast index 75e1be4ce..098445ef7 100644 --- a/test/llvm_autogenerated/switch.wast +++ b/test/llvm_autogenerated/switch.wast @@ -12,39 +12,39 @@ (func $bar32 (param $$0 i32) (block $fake_return_waka123 (block - (block $.LBB0_8 + (block $label$0 (br_if (i32.gt_u (get_local $$0) (i32.const 23) ) - $.LBB0_8 + $label$0 ) - (block $.LBB0_7 - (block $.LBB0_6 - (block $.LBB0_5 - (block $.LBB0_4 - (block $.LBB0_3 - (block $.LBB0_2 + (block $label$1 + (block $label$2 + (block $label$3 + (block $label$4 + (block $label$5 + (block $label$6 (tableswitch (get_local $$0) - (table (br $.LBB0_2) (br $.LBB0_2) (br $.LBB0_2) (br $.LBB0_2) (br $.LBB0_2) (br $.LBB0_2) (br $.LBB0_2) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_3) (br $.LBB0_4) (br $.LBB0_4) (br $.LBB0_4) (br $.LBB0_4) (br $.LBB0_4) (br $.LBB0_4) (br $.LBB0_5) (br $.LBB0_6) (br $.LBB0_7)) (br $.LBB0_2) + (table (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$4) (br $label$4) (br $label$4) (br $label$4) (br $label$4) (br $label$4) (br $label$3) (br $label$2) (br $label$1)) (br $label$6) ) ) (call_import $foo0) - (br $.LBB0_8) + (br $label$0) ) (call_import $foo1) - (br $.LBB0_8) + (br $label$0) ) (call_import $foo2) - (br $.LBB0_8) + (br $label$0) ) (call_import $foo3) - (br $.LBB0_8) + (br $label$0) ) (call_import $foo4) - (br $.LBB0_8) + (br $label$0) ) (call_import $foo5) ) @@ -55,41 +55,41 @@ (func $bar64 (param $$0 i64) (block $fake_return_waka123 (block - (block $.LBB1_8 + (block $label$0 (br_if (i64.gt_u (get_local $$0) (i64.const 23) ) - $.LBB1_8 + $label$0 ) - (block $.LBB1_7 - (block $.LBB1_6 - (block $.LBB1_5 - (block $.LBB1_4 - (block $.LBB1_3 - (block $.LBB1_2 + (block $label$1 + (block $label$2 + (block $label$3 + (block $label$4 + (block $label$5 + (block $label$6 (tableswitch (i32.wrap/i64 (get_local $$0) ) - (table (br $.LBB1_2) (br $.LBB1_2) (br $.LBB1_2) (br $.LBB1_2) (br $.LBB1_2) (br $.LBB1_2) (br $.LBB1_2) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_3) (br $.LBB1_4) (br $.LBB1_4) (br $.LBB1_4) (br $.LBB1_4) (br $.LBB1_4) (br $.LBB1_4) (br $.LBB1_5) (br $.LBB1_6) (br $.LBB1_7)) (br $.LBB1_2) + (table (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$6) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$5) (br $label$4) (br $label$4) (br $label$4) (br $label$4) (br $label$4) (br $label$4) (br $label$3) (br $label$2) (br $label$1)) (br $label$6) ) ) (call_import $foo0) - (br $.LBB1_8) + (br $label$0) ) (call_import $foo1) - (br $.LBB1_8) + (br $label$0) ) (call_import $foo2) - (br $.LBB1_8) + (br $label$0) ) (call_import $foo3) - (br $.LBB1_8) + (br $label$0) ) (call_import $foo4) - (br $.LBB1_8) + (br $label$0) ) (call_import $foo5) ) |