Skip to content

Commit 557eca7

Browse files
committed
fix vacuum bug on nop'ing an if whose body has brs that cause type changes when removed
1 parent d1b598c commit 557eca7

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/passes/Vacuum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
225225
child = curr->ifFalse;
226226
typeUpdater.noteRecursiveRemoval(curr->ifTrue);
227227
} else {
228+
typeUpdater.noteRecursiveRemoval(curr);
228229
ExpressionManipulator::nop(curr);
229230
return;
230231
}

test/passes/vacuum.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,8 @@
301301
)
302302
)
303303
)
304+
(func $nop-if-type-changes (type $0)
305+
(local $0 i32)
306+
(nop)
307+
)
304308
)

test/passes/vacuum.wast

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,4 +637,27 @@
637637
(i32.const 1579493952)
638638
)
639639
)
640+
(func $nop-if-type-changes (type $0)
641+
(local $0 i32)
642+
(block $label$0
643+
(if
644+
(i32.eqz
645+
(get_local $0)
646+
)
647+
(block $label$1
648+
(block
649+
(if ;; we nop this if, which has a type change for block $label$1, no more brs to it
650+
(i32.const 0)
651+
(br_if $label$1
652+
(i32.const 1717966400)
653+
)
654+
)
655+
(drop
656+
(br $label$0)
657+
)
658+
)
659+
)
660+
)
661+
)
662+
)
640663
)

0 commit comments

Comments
 (0)