[llvm] r270619 - LiveIntervalAnalysis: Fix handleMove() re-using the wrong value number
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 14:54:01 PDT 2016
Author: matze
Date: Tue May 24 16:54:01 2016
New Revision: 270619
URL: http://llvm.org/viewvc/llvm-project?rev=270619&view=rev
Log:
LiveIntervalAnalysis: Fix handleMove() re-using the wrong value number
This fixes http://llvm.org/PR27856
Modified:
llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
llvm/trunk/unittests/MI/LiveIntervalTest.cpp
Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=270619&r1=270618&r2=270619&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue May 24 16:54:01 2016
@@ -1257,20 +1257,16 @@ private:
// value.
LiveRange::iterator NewSegment = NewIdxIn;
LiveRange::iterator Next = std::next(NewSegment);
- NewSegment->valno = OldIdxVNI;
if (SlotIndex::isEarlierInstr(Next->start, NewIdx)) {
// There is no gap between NewSegment and its predecessor.
*NewSegment = LiveRange::Segment(Next->start, SplitPos,
- NewSegment->valno);
- NewSegment->valno->def = Next->start;
-
- *Next = LiveRange::Segment(SplitPos, Next->end, Next->valno);
+ Next->valno);
+ *Next = LiveRange::Segment(SplitPos, Next->end, OldIdxVNI);
Next->valno->def = SplitPos;
} else {
// There is a gap between NewSegment and its predecessor
// Value becomes live in.
- *NewSegment = LiveRange::Segment(SplitPos, Next->start,
- NewSegment->valno);
+ *NewSegment = LiveRange::Segment(SplitPos, Next->start, OldIdxVNI);
NewSegment->valno->def = SplitPos;
}
} else {
Modified: llvm/trunk/unittests/MI/LiveIntervalTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/MI/LiveIntervalTest.cpp?rev=270619&r1=270618&r2=270619&view=diff
==============================================================================
--- llvm/trunk/unittests/MI/LiveIntervalTest.cpp (original)
+++ llvm/trunk/unittests/MI/LiveIntervalTest.cpp Tue May 24 16:54:01 2016
@@ -109,8 +109,8 @@ private:
* update affected liveness intervals with LiveIntervalAnalysis::handleMove().
*/
static void testHandleMove(MachineFunction &MF, LiveIntervals &LIS,
- unsigned From, unsigned To) {
- MachineBasicBlock &MBB = MF.front();
+ unsigned From, unsigned To, unsigned BlockNum = 0) {
+ MachineBasicBlock &MBB = *MF.getBlockNumbered(BlockNum);
unsigned I = 0;
MachineInstr *FromInstr = nullptr;
@@ -307,6 +307,28 @@ TEST(LiveIntervalTest, MoveUndefUse) {
});
}
+TEST(LiveIntervalTest, MoveUpValNos) {
+ // handleMoveUp() had a bug where it would reuse the value number of the
+ // destination segment, even though we have no guarntee that this valno wasn't
+ // used in other segments.
+ liveIntervalTest(
+" successors: %bb.1, %bb.2\n"
+" %0 = IMPLICIT_DEF\n"
+" JG_1 %bb.2, implicit %eflags\n"
+" JMP_1 %bb.1\n"
+" bb.2:\n"
+" NOOP implicit %0\n"
+" bb.1:\n"
+" successors: %bb.2\n"
+" %0 = IMPLICIT_DEF implicit %0(tied-def 0)\n"
+" %0 = IMPLICIT_DEF implicit %0(tied-def 0)\n"
+" %0 = IMPLICIT_DEF implicit %0(tied-def 0)\n"
+" JMP_1 %bb.2\n",
+ [](MachineFunction &MF, LiveIntervals &LIS) {
+ testHandleMove(MF, LIS, 2, 0, 2);
+ });
+}
+
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
initLLVM();
More information about the llvm-commits
mailing list