forked from OSchip/llvm-project
[SCCP][IR] Landing pads are not safe to remove
For landingpads with {} type, SCCP ended up dropping them, because we considered them as safe to remove.
This commit is contained in:
parent
64721a3312
commit
da48f08abf
|
@ -698,7 +698,7 @@ bool Instruction::mayHaveSideEffects() const {
|
|||
|
||||
bool Instruction::isSafeToRemove() const {
|
||||
return (!isa<CallInst>(this) || !this->mayHaveSideEffects()) &&
|
||||
!this->isTerminator();
|
||||
!this->isTerminator() && !this->isEHPad();
|
||||
}
|
||||
|
||||
bool Instruction::willReturn() const {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -ipsccp < %s | FileCheck %s
|
||||
|
||||
; SCCP should never remove landingpads.
|
||||
|
||||
declare void @fn()
|
||||
|
||||
define void @test() personality i8* null {
|
||||
; CHECK-LABEL: @test(
|
||||
; CHECK-NEXT: invoke void @fn()
|
||||
; CHECK-NEXT: to label [[SUCCESS:%.*]] unwind label [[FAILURE:%.*]]
|
||||
; CHECK: success:
|
||||
; CHECK-NEXT: ret void
|
||||
; CHECK: failure:
|
||||
; CHECK-NEXT: [[PAD:%.*]] = landingpad {}
|
||||
; CHECK-NEXT: cleanup
|
||||
; CHECK-NEXT: unreachable
|
||||
;
|
||||
invoke void @fn()
|
||||
to label %success unwind label %failure
|
||||
|
||||
success:
|
||||
ret void
|
||||
|
||||
failure:
|
||||
%pad = landingpad {}
|
||||
cleanup
|
||||
unreachable
|
||||
}
|
Loading…
Reference in New Issue