Skip to content

Commit d1b598c

Browse files
committed
add missing finalizations in removeUnusedBrs, when we change an if side and its outer block, we need to finalize the if first and then the block containing it
1 parent a2e1702 commit d1b598c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/passes/RemoveUnusedBrs.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
226226
// we need the ifTrue to break, so it cannot reach the code we want to move
227227
if (ExpressionAnalyzer::obviouslyDoesNotFlowOut(iff->ifTrue)) {
228228
iff->ifFalse = builder.stealSlice(block, i + 1, list.size());
229+
iff->finalize();
230+
block->finalize();
229231
return true;
230232
}
231233
} else {
@@ -262,9 +264,13 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
262264

263265
if (ExpressionAnalyzer::obviouslyDoesNotFlowOut(iff->ifTrue)) {
264266
iff->ifFalse = blockifyMerge(iff->ifFalse, builder.stealSlice(block, i + 1, list.size()));
267+
iff->finalize();
268+
block->finalize();
265269
return true;
266270
} else if (ExpressionAnalyzer::obviouslyDoesNotFlowOut(iff->ifFalse)) {
267271
iff->ifTrue = blockifyMerge(iff->ifTrue, builder.stealSlice(block, i + 1, list.size()));
272+
iff->finalize();
273+
block->finalize();
268274
return true;
269275
}
270276
}

0 commit comments

Comments
 (0)