Skip to content

Commit 96e9398

Browse files
committed
when finalizing a block in MergeBlocks, use its type, so that we don't need to consider type changes for its parent (changing it from a forced i32 to an unreachable might mean the parent needs to become unreachable too)
1 parent 93dcb15 commit 96e9398

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/passes/MergeBlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static void optimizeBlock(Block* curr, Module* module) {
213213
break;
214214
}
215215
}
216-
if (changed) curr->finalize();
216+
if (changed) curr->finalize(curr->type);
217217
}
218218

219219
void BreakValueDropper::visitBlock(Block* curr) {

test/passes/merge-blocks.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,17 @@
8787
)
8888
)
8989
)
90+
(func $drop-block-squared-iloop (type $0)
91+
(drop
92+
(block $label$0 (result i32)
93+
(block $label$1
94+
(drop
95+
(loop $label$2
96+
(br $label$2)
97+
)
98+
)
99+
)
100+
)
101+
)
102+
)
90103
)

test/passes/merge-blocks.wast

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,18 @@
6969
)
7070
)
7171
)
72+
(func $drop-block-squared-iloop
73+
(drop
74+
(block $label$0 (result i32) ;; this block's type should not change, so the drop remains none and valid
75+
(drop
76+
(block $label$1
77+
(loop $label$2
78+
(br $label$2)
79+
)
80+
)
81+
)
82+
)
83+
)
84+
)
7285
)
7386

0 commit comments

Comments
 (0)