Skip to content

Commit

Permalink
[Local] Don't remove invoke of non-willreturn function
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
nikic authored and tstellar committed Jun 3, 2022
1 parent 885724c commit 99b5eb2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions llvm/test/Transforms/SimplifyCFG/invoke.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 99b5eb2

Please sign in to comment.