diff options
author | Matthias Braun <matze@braunis.de> | 2016-05-24 21:54:01 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2016-05-24 21:54:01 +0000 |
commit | fc4c8a1e46ea2d92c0093b44d800955c2b87cdc0 (patch) | |
tree | 102f1f1f39bd198348714ca49a1ae97547e47fe7 /llvm/unittests/MI | |
parent | 94ddce2c0e27d40813086823487eaabcccd97b7b (diff) | |
download | llvm-fc4c8a1e46ea2d92c0093b44d800955c2b87cdc0.zip llvm-fc4c8a1e46ea2d92c0093b44d800955c2b87cdc0.tar.gz llvm-fc4c8a1e46ea2d92c0093b44d800955c2b87cdc0.tar.bz2 |
LiveIntervalAnalysis: Fix handleMove() re-using the wrong value number
This fixes http://llvm.org/PR27856
llvm-svn: 270619
Diffstat (limited to 'llvm/unittests/MI')
-rw-r--r-- | llvm/unittests/MI/LiveIntervalTest.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/llvm/unittests/MI/LiveIntervalTest.cpp b/llvm/unittests/MI/LiveIntervalTest.cpp index dc555c1..e456736 100644 --- a/llvm/unittests/MI/LiveIntervalTest.cpp +++ b/llvm/unittests/MI/LiveIntervalTest.cpp @@ -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(); |