[PATCH] D119266: [SimplifyCFG] Do not merge landingpads for invokes with deopt state.
Denis Antrushin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 8 11:20:25 PST 2022
dantrushin updated this revision to Diff 406906.
dantrushin marked an inline comment as done.
dantrushin added a comment.
Update test checks
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119266/new/
https://reviews.llvm.org/D119266
Files:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/duplicate-landingpad.ll
Index: llvm/test/Transforms/SimplifyCFG/duplicate-landingpad.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/duplicate-landingpad.ll
+++ llvm/test/Transforms/SimplifyCFG/duplicate-landingpad.ll
@@ -147,3 +147,52 @@
call void @fn()
ret void
}
+
+; Should not trigger when invokes have deopt bundles
+define void @neg3() gc "statepoint-example" personality i32 (...)* @__gxx_personality_v0 {
+; CHECK-LABEL: @neg3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: invoke void @fn() [ "deopt"() ]
+; CHECK-NEXT: to label [[INVOKE2:%.*]] unwind label [[LPAD1:%.*]]
+; CHECK: invoke2:
+; CHECK-NEXT: invoke void @fn() [ "deopt"() ]
+; CHECK-NEXT: to label [[COMMON_RET:%.*]] unwind label [[LPAD2:%.*]]
+; CHECK: common.ret:
+; CHECK-NEXT: ret void
+; CHECK: lpad1:
+; CHECK-NEXT: [[EXN:%.*]] = landingpad { i8*, i32 }
+; CHECK-NEXT: cleanup
+; CHECK-NEXT: br label [[SHARED_RESUME:%.*]]
+; CHECK: lpad2:
+; CHECK-NEXT: [[EXN2:%.*]] = landingpad { i8*, i32 }
+; CHECK-NEXT: cleanup
+; CHECK-NEXT: br label [[SHARED_RESUME]]
+; CHECK: shared_resume:
+; CHECK-NEXT: call void @fn()
+; CHECK-NEXT: br label [[COMMON_RET]]
+;
+entry:
+ invoke void @fn() [ "deopt"() ]
+ to label %invoke2 unwind label %lpad1
+
+invoke2:
+ invoke void @fn() [ "deopt"() ]
+ to label %invoke.cont unwind label %lpad2
+
+invoke.cont:
+ ret void
+
+lpad1:
+ %exn = landingpad {i8*, i32}
+ cleanup
+ br label %shared_resume
+
+lpad2:
+ %exn2 = landingpad {i8*, i32}
+ cleanup
+ br label %shared_resume
+
+shared_resume:
+ call void @fn()
+ ret void
+}
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6652,6 +6652,15 @@
/// merged. In some cases, this could result in removal of the PHI entirely.
static bool TryToMergeLandingPad(LandingPadInst *LPad, BranchInst *BI,
BasicBlock *BB, DomTreeUpdater *DTU) {
+
+ // Invokes with deopt bundles must have unique landingpads
+ // (See RewriteStatepointsForGC.cpp). Prohibit landingpad merging
+ // for such invokes.
+ BasicBlock *Pred = *pred_begin(BB);
+ if (auto *Invoke = dyn_cast<InvokeInst>(Pred->getTerminator()))
+ if (Invoke->getOperandBundle(LLVMContext::OB_deopt))
+ return false;
+
auto Succ = BB->getUniqueSuccessor();
assert(Succ);
// If there's a phi in the successor block, we'd likely have to introduce
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119266.406906.patch
Type: text/x-patch
Size: 2593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220208/a9fa9556/attachment-0001.bin>
More information about the llvm-commits
mailing list