aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2022-02-05 02:29:28 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2022-02-05 02:30:20 +0300
commitdb1176ce66cf276b45ac3b90ea6b5ce62de56be7 (patch)
treeef992058cf51dc64f3946e257d0da9624c4e2346 /llvm/lib/Transforms/Utils/Local.cpp
parent981f0a14f1de1455abc092c0692e5c78a16f24a7 (diff)
downloadllvm-db1176ce66cf276b45ac3b90ea6b5ce62de56be7.zip
llvm-db1176ce66cf276b45ac3b90ea6b5ce62de56be7.tar.gz
llvm-db1176ce66cf276b45ac3b90ea6b5ce62de56be7.tar.bz2
Revert "[SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d `noreturn` function is `unreachable`"
The normal destination may have other uses. This reverts commit 598833c987593ce192fa827f162cae8c867c9d43.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp39
1 files changed, 13 insertions, 26 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 58eb7d4..9a10535 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2349,32 +2349,19 @@ static bool markAliveBlocks(Function &F,
isa<UndefValue>(Callee)) {
changeToUnreachable(II, false, DTU);
Changed = true;
- } else {
- if (II->doesNotReturn()) {
- // If we found an invoke of a no-return function,
- // insert an unreachable instruction after it (on the normal dest).
- // Make sure there isn't *already* one there though.
- Instruction *FirstNormalInst = &II->getNormalDest()->front();
- if (!isa<UnreachableInst>(FirstNormalInst)) {
- // Don't insert a call to llvm.trap right before the unreachable.
- changeToUnreachable(FirstNormalInst, false, DTU);
- Changed = true;
- }
- }
- if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
- if (II->use_empty() && II->onlyReadsMemory()) {
- // jump to the normal destination branch.
- BasicBlock *NormalDestBB = II->getNormalDest();
- BasicBlock *UnwindDestBB = II->getUnwindDest();
- BranchInst::Create(NormalDestBB, II);
- UnwindDestBB->removePredecessor(II->getParent());
- II->eraseFromParent();
- if (DTU)
- DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDestBB}});
- } else
- changeToCall(II, DTU);
- Changed = true;
- }
+ } else if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
+ if (II->use_empty() && II->onlyReadsMemory()) {
+ // jump to the normal destination branch.
+ BasicBlock *NormalDestBB = II->getNormalDest();
+ BasicBlock *UnwindDestBB = II->getUnwindDest();
+ BranchInst::Create(NormalDestBB, II);
+ UnwindDestBB->removePredecessor(II->getParent());
+ II->eraseFromParent();
+ if (DTU)
+ DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDestBB}});
+ } else
+ changeToCall(II, DTU);
+ Changed = true;
}
} else if (auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Terminator)) {
// Remove catchpads which cannot be reached.