Skip to content

Commit 99b5eb2

Browse files
nikictstellar
authored andcommitted
[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 2e101cc)
1 parent 885724c commit 99b5eb2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ static bool markAliveBlocks(Function &F,
23502350
changeToUnreachable(II, false, DTU);
23512351
Changed = true;
23522352
} else if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
2353-
if (II->use_empty() && II->onlyReadsMemory()) {
2353+
if (II->use_empty() && !II->mayHaveSideEffects()) {
23542354
// jump to the normal destination branch.
23552355
BasicBlock *NormalDestBB = II->getNormalDest();
23562356
BasicBlock *UnwindDestBB = II->getUnwindDest();

llvm/test/Transforms/SimplifyCFG/invoke.ll

Lines changed: 1 addition & 0 deletions
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)