[llvm-branch-commits] [llvm] 99b5eb2 - [Local] Don't remove invoke of non-willreturn function
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jun 3 06:28:40 PDT 2022
Author: Nikita Popov
Date: 2022-06-03T06:27:20-07:00
New Revision: 99b5eb2d3a61b55a61849cebabf1d5d66b4a13c4
URL: https://github.com/llvm/llvm-project/commit/99b5eb2d3a61b55a61849cebabf1d5d66b4a13c4
DIFF: https://github.com/llvm/llvm-project/commit/99b5eb2d3a61b55a61849cebabf1d5d66b4a13c4.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.
(cherry picked from commit 2e101cca690645d63ae4de1eb7b0e11d322448fd)
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 9a10535c93101..1c350a2585d08 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2350,7 +2350,7 @@ static bool markAliveBlocks(Function &F,
changeToUnreachable(II, false, DTU);
Changed = true;
} else 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 db10fa390c1dc..175a2c6aadc64 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-branch-commits
mailing list