aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2023-01-13 20:44:41 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2023-01-13 21:04:17 +0300
commit333cdd41255adb122b1a3cedac5bc6aef5c0982c (patch)
treee341dad3bb6f4be47bb72028d56461febda72135 /llvm/lib/Transforms/Utils/Local.cpp
parent6ca1a09f03e8e940f306bea73efa935e4ee38173 (diff)
downloadllvm-333cdd41255adb122b1a3cedac5bc6aef5c0982c.zip
llvm-333cdd41255adb122b1a3cedac5bc6aef5c0982c.tar.gz
llvm-333cdd41255adb122b1a3cedac5bc6aef5c0982c.tar.bz2
[SimplifyCFG] Reapply: when eliminating `unreachable` landing pads, mark `call`s as `nounwind`
This time the change is in it's least intrusive form since only the return type in prototype for `removeUnwindEdge()` is changed, since only a single specific caller need that knowledge. We really can't recover that knowledge, and `nounwind` knowledge, (and not just a lack of the unwind edge, aka `call` instead of `invoke`), is e.g. part of the reasoning in e.g. `mayHaveSideEffects()`. Note that this is call-site-specific knowledge, just because some callsite had an `unreachable` unwind edge, does not mean that all will.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index d5d0232..a8a7b64 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2557,13 +2557,11 @@ static bool markAliveBlocks(Function &F,
return Changed;
}
-void llvm::removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU) {
+Instruction *llvm::removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU) {
Instruction *TI = BB->getTerminator();
- if (auto *II = dyn_cast<InvokeInst>(TI)) {
- changeToCall(II, DTU);
- return;
- }
+ if (auto *II = dyn_cast<InvokeInst>(TI))
+ return changeToCall(II, DTU);
Instruction *NewTI;
BasicBlock *UnwindDest;
@@ -2591,6 +2589,7 @@ void llvm::removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU) {
TI->eraseFromParent();
if (DTU)
DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDest}});
+ return NewTI;
}
/// removeUnreachableBlocks - Remove blocks that are not reachable, even