Skip to content

Commit 2e101cc

Browse files
committed
[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.
1 parent 1f1de06 commit 2e101cc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

llvm/lib/Transforms/Utils/Local.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,7 @@ static bool markAliveBlocks(Function &F,
23662366
Changed = true;
23672367
}
23682368
if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
2369-
if (II->use_empty() && II->onlyReadsMemory()) {
2369+
if (II->use_empty() && !II->mayHaveSideEffects()) {
23702370
// jump to the normal destination branch.
23712371
BasicBlock *NormalDestBB = II->getNormalDest();
23722372
BasicBlock *UnwindDestBB = II->getUnwindDest();

llvm/test/Transforms/SimplifyCFG/invoke.ll

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ lpad:
8383
define i32 @invoke_readonly_may_not_return() nounwind personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
8484
; CHECK-LABEL: @invoke_readonly_may_not_return(
8585
; CHECK-NEXT: entry:
86+
; CHECK-NEXT: [[CALL:%.*]] = call i32 @readonly()
8687
; CHECK-NEXT: ret i32 3
8788
;
8889
entry:

0 commit comments

Comments
 (0)