[PATCH] D98728: [LICM] Fix a crash when sinking instructions w/token operands
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 17 11:19:00 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c7f4676cd42: [LICM] Fix a crash when sinking instructions w/token operands (authored by reames).
Changed prior to commit:
https://reviews.llvm.org/D98728?vs=331050&id=331328#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98728/new/
https://reviews.llvm.org/D98728
Files:
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/test/Transforms/LICM/gc-relocate.ll
Index: llvm/test/Transforms/LICM/gc-relocate.ll
===================================================================
--- llvm/test/Transforms/LICM/gc-relocate.ll
+++ llvm/test/Transforms/LICM/gc-relocate.ll
@@ -10,18 +10,17 @@
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[TMP:%.*]] = call token (i64, i32, i32 (i32, i8 addrspace(1)*, i32, i32, i32)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32i32p1i8i32i32i32f(i64 1, i32 16, i32 (i32, i8 addrspace(1)*, i32, i32, i32)* nonnull @zot, i32 5, i32 0, i32 undef, i8 addrspace(1)* undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0) [ "deopt"(i32 0, i32 0, i32 0, i32 235, i32 3, i32 32, i32 0, i32 0, i8 addrspace(1)* undef, i32 3, i32 undef, i32 3, float undef, i32 0, i8 addrspace(1)* undef, i32 7, i8* null, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 0, i8 addrspace(1)* undef, i32 4, double undef, i32 7, i8* null, i32 0, i8 addrspace(1)* undef, i32 3, float undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* null, i32 3, i32 -15108, i32 7, i8* null, i32 7, i8* null, i32 7, i8* null, i32 7, i8* null, i32 7, i8* null), "gc-live"(i8 addrspace(1)* [[ARG:%.*]]) ]
-; CHECK-NEXT: [[RES:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TMP]], i32 0, i32 0)
; CHECK-NEXT: br i1 false, label [[BB1]], label [[BB2:%.*]]
; CHECK: bb2:
-; CHECK-NEXT: [[RES_LCSSA:%.*]] = phi i8 addrspace(1)* [ [[RES]], [[BB1]] ]
-; CHECK-NEXT: ret i8 addrspace(1)* [[RES_LCSSA]]
+; CHECK-NEXT: [[RES_LE:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[TMP]], i32 0, i32 0) #[[ATTR2:[0-9]+]]
+; CHECK-NEXT: ret i8 addrspace(1)* [[RES_LE]]
;
bb:
br label %bb1
bb1:
%tmp = call token (i64, i32, i32 (i32, i8 addrspace(1)*, i32, i32, i32)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32i32p1i8i32i32i32f(i64 1, i32 16, i32 (i32, i8 addrspace(1)*, i32, i32, i32)* nonnull @zot, i32 5, i32 0, i32 undef, i8 addrspace(1)* undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0) [ "deopt"(i32 0, i32 0, i32 0, i32 235, i32 3, i32 32, i32 0, i32 0, i8 addrspace(1)* undef, i32 3, i32 undef, i32 3, float undef, i32 0, i8 addrspace(1)* undef, i32 7, i8* null, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 3, i32 undef, i32 0, i8 addrspace(1)* undef, i32 4, double undef, i32 7, i8* null, i32 0, i8 addrspace(1)* undef, i32 3, float undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* undef, i32 0, i8 addrspace(1)* null, i32 3, i32 -15108, i32 7, i8* null, i32 7, i8* null, i32 7, i8* null, i32 7, i8* null, i32 7, i8* null), "gc-live"(i8 addrspace(1)* %arg) ]
- %res = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %tmp, i32 0, i32 0)
+ %res = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %tmp, i32 0, i32 0) readnone
br i1 undef, label %bb1, label %bb2
bb2:
Index: llvm/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LICM.cpp
+++ llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1502,8 +1502,8 @@
}
}
- // Build LCSSA PHI nodes for any in-loop operands. Note that this is
- // particularly cheap because we can rip off the PHI node that we're
+ // Build LCSSA PHI nodes for any in-loop operands (if legal). Note that
+ // this is particularly cheap because we can rip off the PHI node that we're
// replacing for the number and blocks of the predecessors.
// OPT: If this shows up in a profile, we can instead finish sinking all
// invariant instructions, and then walk their operands to re-establish
@@ -1512,7 +1512,7 @@
for (Use &Op : New->operands())
if (Instruction *OInst = dyn_cast<Instruction>(Op))
if (Loop *OLoop = LI->getLoopFor(OInst->getParent()))
- if (!OLoop->contains(&PN)) {
+ if (!OLoop->contains(&PN) && !Op->getType()->isTokenTy()) {
PHINode *OpPN =
PHINode::Create(OInst->getType(), PN.getNumIncomingValues(),
OInst->getName() + ".lcssa", &ExitBlock.front());
@@ -1856,10 +1856,13 @@
AAMDNodes AATags;
ICFLoopSafetyInfo &SafetyInfo;
+ // We're about to add a use of V in a loop exit block. Insert an LCSSA phi
+ // (if legal) if doing so would add an out-of-loop use to an instruction
+ // defined in-loop.
Value *maybeInsertLCSSAPHI(Value *V, BasicBlock *BB) const {
if (Instruction *I = dyn_cast<Instruction>(V))
if (Loop *L = LI.getLoopFor(I->getParent()))
- if (!L->contains(BB)) {
+ if (!L->contains(BB) && !I->getType()->isTokenTy()) {
// We need to create an LCSSA PHI node for the incoming value and
// store that.
PHINode *PN = PHINode::Create(I->getType(), PredCache.size(BB),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98728.331328.patch
Type: text/x-patch
Size: 5409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210317/9aa1bab0/attachment.bin>
More information about the llvm-commits
mailing list