Skip to content

Commit 29cf873

Browse files
committed
note changes when removing an if body in vacuum
1 parent f755250 commit 29cf873

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

src/passes/Vacuum.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
234234
}
235235
// if the condition is unreachable, just return it
236236
if (curr->condition->type == unreachable) {
237+
typeUpdater.noteRecursiveRemoval(curr->ifTrue);
238+
if (curr->ifFalse) {
239+
typeUpdater.noteRecursiveRemoval(curr->ifFalse);
240+
}
237241
replaceCurrent(curr->condition);
238242
return;
239243
}

test/passes/vacuum.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,18 @@
287287
)
288288
)
289289
)
290+
(func $if-arm-vanishes (type $3) (result i32)
291+
(block $label$0 (result i32)
292+
(br $label$0
293+
(i32.const 1)
294+
)
295+
)
296+
)
297+
(func $if-arm-vanishes-2 (type $3) (result i32)
298+
(block $label$0 (result i32)
299+
(br $label$0
300+
(i32.const 1)
301+
)
302+
)
303+
)
290304
)

test/passes/vacuum.wast

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,30 @@
611611
)
612612
)
613613
)
614+
(func $if-arm-vanishes (result i32)
615+
(block $label$0 (result i32)
616+
(block $label$1
617+
(if
618+
(br $label$0
619+
(i32.const 1)
620+
)
621+
(br $label$1)
622+
)
623+
)
624+
(i32.const 1579493952)
625+
)
626+
)
627+
(func $if-arm-vanishes-2 (result i32)
628+
(block $label$0 (result i32)
629+
(block $label$1
630+
(if
631+
(br $label$0
632+
(i32.const 1)
633+
)
634+
(br $label$1)
635+
)
636+
)
637+
(i32.const 1579493952)
638+
)
639+
)
614640
)

0 commit comments

Comments
 (0)