[llvm] r272446 - LiveIntervalAnalysis: findLastUseBefore() must ignore undef uses.
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 10 17:31:29 PDT 2016
Author: matze
Date: Fri Jun 10 19:31:28 2016
New Revision: 272446
URL: http://llvm.org/viewvc/llvm-project?rev=272446&view=rev
Log:
LiveIntervalAnalysis: findLastUseBefore() must ignore undef uses.
undef uses are no real uses of a register and must be ignored by
findLastUseBefore() so that handleMove() does not produce invalid live
intervals in some cases.
This fixed http://llvm.org/PR28083
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=272446&r1=272445&r2=272446&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Jun 10 19:31:28 2016
@@ -1314,6 +1314,8 @@ private:
if (TargetRegisterInfo::isVirtualRegister(Reg)) {
SlotIndex LastUse = Before;
for (MachineOperand &MO : MRI.use_nodbg_operands(Reg)) {
+ if (MO.isUndef())
+ continue;
unsigned SubReg = MO.getSubReg();
if (SubReg != 0 && LaneMask != 0
&& (TRI.getSubRegIndexLaneMask(SubReg) & LaneMask) == 0)
@@ -1353,7 +1355,7 @@ private:
// Check if MII uses Reg.
for (MIBundleOperands MO(*MII); MO.isValid(); ++MO)
- if (MO->isReg() &&
+ if (MO->isReg() && !MO->isUndef() &&
TargetRegisterInfo::isPhysicalRegister(MO->getReg()) &&
TRI.hasRegUnit(MO->getReg(), Reg))
return Idx.getRegSlot();
Modified: llvm/trunk/unittests/MI/LiveIntervalTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/MI/LiveIntervalTest.cpp?rev=272446&r1=272445&r2=272446&view=diff
==============================================================================
--- llvm/trunk/unittests/MI/LiveIntervalTest.cpp (original)
+++ llvm/trunk/unittests/MI/LiveIntervalTest.cpp Fri Jun 10 19:31:28 2016
@@ -329,6 +329,30 @@ TEST(LiveIntervalTest, MoveUpValNos) {
});
}
+TEST(LiveIntervalTest, MoveOverUndefUse0) {
+ // findLastUseBefore() used by handleMoveUp() must ignore undef operands.
+ liveIntervalTest(
+" %0 = IMPLICIT_DEF\n"
+" NOOP\n"
+" NOOP implicit undef %0\n"
+" %0 = IMPLICIT_DEF implicit %0(tied-def 0)\n",
+ [](MachineFunction &MF, LiveIntervals &LIS) {
+ testHandleMove(MF, LIS, 3, 1);
+ });
+}
+
+TEST(LiveIntervalTest, MoveOverUndefUse1) {
+ // findLastUseBefore() used by handleMoveUp() must ignore undef operands.
+ liveIntervalTest(
+" %rax = IMPLICIT_DEF\n"
+" NOOP\n"
+" NOOP implicit undef %rax\n"
+" %rax = IMPLICIT_DEF implicit %rax(tied-def 0)\n",
+ [](MachineFunction &MF, LiveIntervals &LIS) {
+ testHandleMove(MF, LIS, 3, 1);
+ });
+}
+
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
initLLVM();
More information about the llvm-commits
mailing list