Skip to content

Commit 5c4c6ba

Browse files
committed
properly handle if arm removal in vacuum
1 parent 9870039 commit 5c4c6ba

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

src/passes/Vacuum.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,13 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
204204
Expression* child;
205205
if (value->value.getInteger()) {
206206
child = curr->ifTrue;
207+
if (curr->ifFalse) {
208+
typeUpdater.noteRecursiveRemoval(curr->ifFalse);
209+
}
207210
} else {
208211
if (curr->ifFalse) {
209212
child = curr->ifFalse;
213+
typeUpdater.noteRecursiveRemoval(curr->ifTrue);
210214
} else {
211215
ExpressionManipulator::nop(curr);
212216
return;

test/passes/vacuum.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,16 @@
235235
)
236236
)
237237
)
238+
(func $executed-if-in-block (type $0)
239+
(unreachable)
240+
)
241+
(func $executed-if-in-block2 (type $0)
242+
(unreachable)
243+
)
244+
(func $executed-if-in-block3 (type $0)
245+
(block $label$0
246+
(br $label$0)
247+
)
248+
(unreachable)
249+
)
238250
)

test/passes/vacuum.wast

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,34 @@
534534
(f64.const 2097914503796645752267195e31)
535535
)
536536
)
537+
(func $executed-if-in-block
538+
(block $label$0
539+
(if
540+
(i32.const 170996275)
541+
(unreachable)
542+
(br $label$0)
543+
)
544+
)
545+
(unreachable)
546+
)
547+
(func $executed-if-in-block2
548+
(block $label$0
549+
(if
550+
(i32.const 170996275)
551+
(nop)
552+
(br $label$0)
553+
)
554+
)
555+
(unreachable)
556+
)
557+
(func $executed-if-in-block3
558+
(block $label$0
559+
(if
560+
(i32.const 170996275)
561+
(br $label$0)
562+
(nop)
563+
)
564+
)
565+
(unreachable)
566+
)
537567
)

0 commit comments

Comments
 (0)