File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -545,7 +545,7 @@ void WasmBinaryWriter::recurse(Expression*& curr) {
545545}
546546
547547static bool brokenTo (Block* block) {
548- return block->name .is () && BranchUtils::BranchSeeker::has (block, block->name );
548+ return block->name .is () && BranchUtils::BranchSeeker::hasNamed (block, block->name );
549549}
550550
551551void WasmBinaryWriter::visitBlock (Block *curr) {
@@ -636,7 +636,7 @@ int32_t WasmBinaryWriter::getBreakIndex(Name name) { // -1 if not found
636636 return breakStack.size () - 1 - i;
637637 }
638638 }
639- std::cerr << " bad break: " << name << std::endl;
639+ std::cerr << " bad break: " << name << " in " << currFunction-> name << std::endl;
640640 abort ();
641641}
642642
@@ -2070,7 +2070,14 @@ void WasmBinaryBuilder::visitBlock(Block *curr) {
20702070 }
20712071 for (size_t i = start; i < end; i++) {
20722072 if (debug) std::cerr << " " << size_t (expressionStack[i]) << " \n zz Block element " << curr->list .size () << std::endl;
2073- curr->list .push_back (expressionStack[i]);
2073+ auto * item = expressionStack[i];
2074+ curr->list .push_back (item);
2075+ if (i < end - 1 ) {
2076+ // stacky&unreachable code may introduce elements that need to be dropped in non-final positoins
2077+ if (isConcreteWasmType (item->type )) {
2078+ curr->list .back () = Builder (wasm).makeDrop (curr->list .back ());
2079+ }
2080+ }
20742081 }
20752082 expressionStack.resize (start);
20762083 curr->finalize (curr->type );
Original file line number Diff line number Diff line change 1+ (module
2+ (func $binaryify-untaken-br_if (result f32 )
3+ (if
4+ (i32.const 1 )
5+ (unreachable )
6+ (block $label$1
7+ (br_if $label$1
8+ (i32.const 1 )
9+ (unreachable )
10+ )
11+ )
12+ )
13+ )
14+ )
Original file line number Diff line number Diff line change 1+ (module
2+ (type $0 (func (result f32)))
3+ (memory $0 0)
4+ (func $binaryify-untaken-br_if (type $0) (result f32)
5+ (if
6+ (i32.const 1)
7+ (unreachable)
8+ (block $label$1
9+ (br_if $label$1
10+ (i32.const 1)
11+ (unreachable)
12+ )
13+ )
14+ )
15+ )
16+ )
Original file line number Diff line number Diff line change 1+ (module
2+ (type $0 (func (result f32)))
3+ (memory $0 0)
4+ (func $binaryify-untaken-br_if (type $0) (result f32)
5+ (if
6+ (i32.const 1)
7+ (block $label$0
8+ (unreachable)
9+ )
10+ (block $label$1
11+ (block $label$2
12+ (drop
13+ (i32.const 1)
14+ )
15+ (br_if $label$2
16+ (unreachable)
17+ )
18+ (unreachable)
19+ )
20+ (unreachable)
21+ )
22+ )
23+ (unreachable)
24+ )
25+ )
26+
Original file line number Diff line number Diff line change 1+ (module
2+ (type $0 (func (result f32)))
3+ (memory $0 0)
4+ (func $0 (type $0) (result f32)
5+ (if
6+ (i32.const 1)
7+ (block $label$0
8+ (unreachable)
9+ )
10+ (block $label$1
11+ (block $label$2
12+ (drop
13+ (i32.const 1)
14+ )
15+ (br_if $label$2
16+ (unreachable)
17+ )
18+ (unreachable)
19+ )
20+ (unreachable)
21+ )
22+ )
23+ (unreachable)
24+ )
25+ )
26+
You can’t perform that action at this time.
0 commit comments