[PATCH] D82110: [LiveIntervals] Fix early-clobber handling in handleMoveUp
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 18 10:54:11 PDT 2020
foad created this revision.
Herald added subscribers: llvm-commits, hiraditya, MatzeB.
Herald added a project: LLVM.
foad added reviewers: critson, arsenm, tpr, marcello.maggioni, fhahn, atrick, kparzysz.
Herald added a subscriber: wdng.
Without this fix, handleMoveUp can create an invalid live range like
this:
[98904e,98908r:0)[98908e,227504r:1)
where the two segments overlap, but only because we have lost the "e"
(early-clobber) on the end point of the first segment.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82110
Files:
llvm/lib/CodeGen/LiveIntervals.cpp
llvm/unittests/MI/LiveIntervalTest.cpp
Index: llvm/unittests/MI/LiveIntervalTest.cpp
===================================================================
--- llvm/unittests/MI/LiveIntervalTest.cpp
+++ llvm/unittests/MI/LiveIntervalTest.cpp
@@ -443,6 +443,21 @@
});
}
+TEST(LiveIntervalTest, EarlyClobberSubRegMoveUp) {
+ // handleMoveUp had a bug where moving an early-clobber subreg def into the
+ // middle of an earlier segment resulted in an invalid live range.
+ liveIntervalTest(R"MIR(
+ %5704:sreg_32 = IMPLICIT_DEF
+ %5706:sreg_32 = IMPLICIT_DEF
+ undef early-clobber %5709.sub0:sreg_64 = WWM %5704:sreg_32, implicit $exec
+ %5755:sreg_32 = S_FLBIT_I32_B32 %5709.sub0:sreg_64
+ early-clobber %5709.sub1:sreg_64 = WWM %5706:sreg_32, implicit $exec
+ %5757:sreg_32 = S_FLBIT_I32_B32 %5709.sub1:sreg_64
+)MIR", [](MachineFunction &MF, LiveIntervals &LIS) {
+ testHandleMove(MF, LIS, 4, 3);
+ });
+}
+
TEST(LiveIntervalTest, TestMoveSubRegDefAcrossUseDef) {
liveIntervalTest(R"MIR(
%1:vreg_64 = IMPLICIT_DEF
Index: llvm/lib/CodeGen/LiveIntervals.cpp
===================================================================
--- llvm/lib/CodeGen/LiveIntervals.cpp
+++ llvm/lib/CodeGen/LiveIntervals.cpp
@@ -1342,7 +1342,7 @@
OldIdxOut->start = NewIdxDef;
OldIdxVNI->def = NewIdxDef;
if (OldIdxIn != E && SlotIndex::isEarlierInstr(NewIdx, OldIdxIn->end))
- OldIdxIn->end = NewIdx.getRegSlot();
+ OldIdxIn->end = NewIdxDef;
}
} else if (OldIdxIn != E
&& SlotIndex::isEarlierInstr(NewIdxOut->start, NewIdx)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82110.271769.patch
Type: text/x-patch
Size: 1583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200618/34c40e61/attachment.bin>
More information about the llvm-commits
mailing list