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:
endThis 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:
endBut 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.