diff options
author | Carl Ritson <carl.ritson@amd.com> | 2020-04-16 19:57:55 +0900 |
---|---|---|
committer | Carl Ritson <carl.ritson@amd.com> | 2020-04-16 19:58:19 +0900 |
commit | 43e2460a89abf6aace35973c682e1723d5f16f10 (patch) | |
tree | bccb19c77a8a533ad79878fc7536bfb93409a705 /llvm/unittests/MI | |
parent | 94d6dd01ba439ffcef7f7873622cf6ae99bcf5cb (diff) | |
download | llvm-43e2460a89abf6aace35973c682e1723d5f16f10.zip llvm-43e2460a89abf6aace35973c682e1723d5f16f10.tar.gz llvm-43e2460a89abf6aace35973c682e1723d5f16f10.tar.bz2 |
[LiveIntervals] Replace handleMoveIntoBundle
Summary:
The current handleMoveIntoBundle implementation is unusable,
it attempts to access the slot indexes of bundled instructions.
It also leaves bundled instructions with slot indexes assigned.
Replace handleMoveIntoBundle this with a more explicit
handleMoveIntoNewBundle function which recalculates the live
intervals for all instructions moved into a newly formed bundle,
and removes slot indexes from these instructions.
Reviewers: arsenm, MaskRay, kariddi, tpr, qcolombet
Reviewed By: qcolombet
Subscribers: MatzeB, wdng, hiraditya, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77969
Diffstat (limited to 'llvm/unittests/MI')
-rw-r--r-- | llvm/unittests/MI/LiveIntervalTest.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/llvm/unittests/MI/LiveIntervalTest.cpp b/llvm/unittests/MI/LiveIntervalTest.cpp index 835d3f9..f0be970 100644 --- a/llvm/unittests/MI/LiveIntervalTest.cpp +++ b/llvm/unittests/MI/LiveIntervalTest.cpp @@ -128,6 +128,27 @@ static void testHandleMove(MachineFunction &MF, LiveIntervals &LIS, LIS.handleMove(FromInstr, true); } +/** + * Move instructions numbered \p From inclusive through instruction number + * \p To into a newly formed bundle and update affected liveness intervals + * with LiveIntervalAnalysis::handleMoveIntoNewBundle(). + */ +static void testHandleMoveIntoNewBundle(MachineFunction &MF, LiveIntervals &LIS, + unsigned From, unsigned To, + unsigned BlockNum = 0) { + MachineInstr &FromInstr = getMI(MF, From, BlockNum); + MachineInstr &ToInstr = getMI(MF, To, BlockNum); + MachineBasicBlock &MBB = *FromInstr.getParent(); + MachineBasicBlock::instr_iterator I = FromInstr.getIterator(); + + // Build bundle + finalizeBundle(MBB, I, std::next(ToInstr.getIterator())); + + // Update LiveIntervals + MachineBasicBlock::instr_iterator BundleStart = std::prev(I); + LIS.handleMoveIntoNewBundle(*BundleStart, true); +} + static void liveIntervalTest(StringRef MIRFunc, LiveIntervalTest T) { LLVMContext Context; std::unique_ptr<LLVMTargetMachine> TM = createTargetMachine(); @@ -462,6 +483,96 @@ TEST(LiveIntervalTest, TestMoveSubRegDefAcrossUseDefMulti) { testHandleMove(MF, LIS, 4, 1, 1); }); } + +TEST(LiveIntervalTest, BundleUse) { + liveIntervalTest(R"MIR( + %0 = IMPLICIT_DEF + S_NOP 0 + S_NOP 0, implicit %0 + S_NOP 0 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 1, 2); + }); +} + +TEST(LiveIntervalTest, BundleDef) { + liveIntervalTest(R"MIR( + %0 = IMPLICIT_DEF + S_NOP 0 + S_NOP 0, implicit %0 + S_NOP 0 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 0, 1); + }); +} + +TEST(LiveIntervalTest, BundleRedef) { + liveIntervalTest(R"MIR( + %0 = IMPLICIT_DEF + S_NOP 0 + %0 = IMPLICIT_DEF implicit %0(tied-def 0) + S_NOP 0, implicit %0 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 1, 2); + }); +} + +TEST(LiveIntervalTest, BundleInternalUse) { + liveIntervalTest(R"MIR( + %0 = IMPLICIT_DEF + S_NOP 0 + S_NOP 0, implicit %0 + S_NOP 0 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 0, 2); + }); +} + +TEST(LiveIntervalTest, BundleUndefUse) { + liveIntervalTest(R"MIR( + %0 = IMPLICIT_DEF + S_NOP 0 + S_NOP 0, implicit undef %0 + S_NOP 0 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 1, 2); + }); +} + +TEST(LiveIntervalTest, BundleSubRegUse) { + liveIntervalTest(R"MIR( + successors: %bb.1, %bb.2 + undef %0.sub0 = IMPLICIT_DEF + %0.sub1 = IMPLICIT_DEF + S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc + S_BRANCH %bb.1 + bb.1: + S_NOP 0 + S_NOP 0, implicit %0.sub1 + bb.2: + S_NOP 0, implicit %0.sub1 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 0, 1, 1); + }); +} + +TEST(LiveIntervalTest, BundleSubRegDef) { + liveIntervalTest(R"MIR( + successors: %bb.1, %bb.2 + undef %0.sub0 = IMPLICIT_DEF + %0.sub1 = IMPLICIT_DEF + S_CBRANCH_VCCNZ %bb.2, implicit undef $vcc + S_BRANCH %bb.1 + bb.1: + S_NOP 0 + S_NOP 0, implicit %0.sub1 + bb.2: + S_NOP 0, implicit %0.sub1 +)MIR", [](MachineFunction &MF, LiveIntervals &LIS) { + testHandleMoveIntoNewBundle(MF, LIS, 0, 1, 0); + }); +} + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); initLLVM(); |