Fix PR7156. If the sources of a REG_SEQUENCE are all IMPLICIT_DEF's. Replace it with an IMPLICIT_DEF rather than deleting it or else it would be left without a def.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103984 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index fb9bddc..2d43fba 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -1238,6 +1238,7 @@
llvm_unreachable(0);
}
+ bool IsImpDef = true;
SmallVector<unsigned, 4> RealSrcs;
SmallSet<unsigned, 4> Seen;
for (unsigned i = 1, e = MI->getNumOperands(); i < e; i += 2) {
@@ -1253,6 +1254,7 @@
DefMI->eraseFromParent();
continue;
}
+ IsImpDef = false;
// Remember EXTRACT_SUBREG sources. These might be candidate for
// coalescing.
@@ -1297,8 +1299,15 @@
UpdateRegSequenceSrcs(SrcReg, DstReg, SubIdx, MRI);
}
- DEBUG(dbgs() << "Eliminated: " << *MI);
- MI->eraseFromParent();
+ if (IsImpDef) {
+ DEBUG(dbgs() << "Turned: " << *MI << " into an IMPLICIT_DEF");
+ MI->setDesc(TII->get(TargetOpcode::IMPLICIT_DEF));
+ for (int j = MI->getNumOperands() - 1, ee = 0; j > ee; --j)
+ MI->RemoveOperand(j);
+ } else {
+ DEBUG(dbgs() << "Eliminated: " << *MI);
+ MI->eraseFromParent();
+ }
// Try coalescing some EXTRACT_SUBREG instructions.
CoalesceExtSubRegs(RealSrcs, DstReg);