aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2023-01-13 00:05:19 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2023-01-13 00:41:58 +0300
commit3c5b1f2d94d021005ce3769a4402d4a4ae843989 (patch)
treed4edd4ac4633efe13accb33a2aef6271311a22a1 /llvm/lib/Transforms/Utils/Local.cpp
parenta5c23d55842a31eb83b7968866e69d1731411580 (diff)
downloadllvm-3c5b1f2d94d021005ce3769a4402d4a4ae843989.zip
llvm-3c5b1f2d94d021005ce3769a4402d4a4ae843989.tar.gz
llvm-3c5b1f2d94d021005ce3769a4402d4a4ae843989.tar.bz2
[SimplifyCFG] When eliminating `unreachable` landing pads, mark `call`s as `nounwind`
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.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index d5d0232..569eee3 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2557,11 +2557,14 @@ static bool markAliveBlocks(Function &F,
return Changed;
}
-void llvm::removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU) {
+void llvm::removeUnwindEdge(BasicBlock *BB, bool WouldUnwindBeUB,
+ DomTreeUpdater *DTU) {
Instruction *TI = BB->getTerminator();
if (auto *II = dyn_cast<InvokeInst>(TI)) {
- changeToCall(II, DTU);
+ CallInst *CI = changeToCall(II, DTU);
+ if (WouldUnwindBeUB && !CI->doesNotThrow())
+ CI->setDoesNotThrow();
return;
}