[WebAssembly] Fix a bug in removing unnecessary branches
Summary: One of the things `removeUnnecessaryInstrs()` in CFGStackify does is to remove an unnecessary unconditinal branch before an EH pad. When there is an unconditional branch right before a catch instruction and it branches to the end of `end_try` marker, we don't need the branch, because it there is no exception, the control flow transfers to that point anyway. ``` bb0: try ... br bb2 <- Not necessary bb1: catch ... bb2: end ``` This applies when we have a conditional branch followed by an unconditional one, in which case we should only remove the unconditional branch. For example: ``` bb0: try ... br_if someplace_else br bb2 <- Not necessary bb1: catch ... bb2: end ``` But `TargetInstrInfo::removeBranch` we used removed all existing branches when there are multiple ones. This patch fixes it by only deleting the last (= unconditional) branch manually. Also fixes some `preds` comments in the test file. Reviewers: dschuff Subscribers: sbc100, jgravelle-google, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80572
Loading
Please sign in to comment