[PATCH] D80572: [WebbAssembly] Fix a bug in removing unnecessary branches
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 26 09:13:10 PDT 2020
aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, hiraditya, jgravelle-google, sbc100.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80572
Files:
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80572.266244.patch
Type: text/x-patch
Size: 5745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200526/b2e50b32/attachment.bin>
More information about the llvm-commits
mailing list