From: Nikita Popov Date: Mon, 14 Mar 2022 13:34:01 +0000 (+0100) Subject: [SCCP][IR] Landing pads are not safe to remove X-Git-Tag: upstream/15.0.7~13762 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da48f08abf3cb26d1fce4a6909c4fe2e63278d80;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index 9f1d5da..bf76c89 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -698,7 +698,7 @@ bool Instruction::mayHaveSideEffects() const { bool Instruction::isSafeToRemove() const { return (!isa(this) || !this->mayHaveSideEffects()) && - !this->isTerminator(); + !this->isTerminator() && !this->isEHPad(); } bool Instruction::willReturn() const { diff --git a/llvm/test/Transforms/SCCP/landingpad.ll b/llvm/test/Transforms/SCCP/landingpad.ll new file mode 100644 index 0000000..e07ef68 --- /dev/null +++ b/llvm/test/Transforms/SCCP/landingpad.ll @@ -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 +}