[llvm] 2e101cc - [Local] Don't remove invoke of non-willreturn function
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 30 06:39:25 PDT 2022
Author: Nikita Popov
Date: 2022-05-30T15:37:46+02:00
New Revision: 2e101cca690645d63ae4de1eb7b0e11d322448fd
URL: https://github.com/llvm/llvm-project/commit/2e101cca690645d63ae4de1eb7b0e11d322448fd
DIFF: https://github.com/llvm/llvm-project/commit/2e101cca690645d63ae4de1eb7b0e11d322448fd.diff
LOG: [Local] Don't remove invoke of non-willreturn function
The code was only checking for memory side-effects, but not for
divergence side-effects. Replace this with a generic check.
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/SimplifyCFG/invoke.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 5e37f387c19b2..a0609750852bd 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2366,7 +2366,7 @@ static bool markAliveBlocks(Function &F,
Changed = true;
}
if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
- if (II->use_empty() && II->onlyReadsMemory()) {
+ if (II->use_empty() && !II->mayHaveSideEffects()) {
// jump to the normal destination branch.
BasicBlock *NormalDestBB = II->getNormalDest();
BasicBlock *UnwindDestBB = II->getUnwindDest();
diff --git a/llvm/test/Transforms/SimplifyCFG/invoke.ll b/llvm/test/Transforms/SimplifyCFG/invoke.ll
index ef0067f189339..fdbb9e6fbca6f 100644
--- a/llvm/test/Transforms/SimplifyCFG/invoke.ll
+++ b/llvm/test/Transforms/SimplifyCFG/invoke.ll
@@ -83,6 +83,7 @@ lpad:
define i32 @invoke_readonly_may_not_return() nounwind personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
; CHECK-LABEL: @invoke_readonly_may_not_return(
; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CALL:%.*]] = call i32 @readonly()
; CHECK-NEXT: ret i32 3
;
entry:
More information about the llvm-commits
mailing list