[BreakFalseDeps] Harden pickBestRegisterForUndef against changing tied operands or physical registers that aren't renamable.

I don't have any test cases since X86 doesn't return any tied
operands from getUndefRegClearance today. But conceivably we could
want BreakFalseDeps to insert a dependency breaking XOR for
a tied operand in the future.
This commit is contained in:
Craig Topper 2020-05-09 15:33:08 -07:00
parent 57fb56b30e
commit 24b3c2d058
1 changed files with 9 additions and 0 deletions

View File

@ -106,9 +106,18 @@ FunctionPass *llvm::createBreakFalseDeps() { return new BreakFalseDeps(); }
bool BreakFalseDeps::pickBestRegisterForUndef(MachineInstr *MI, unsigned OpIdx,
unsigned Pref) {
// We can't change tied operands.
if (MI->isRegTiedToDefOperand(OpIdx))
return false;
MachineOperand &MO = MI->getOperand(OpIdx);
assert(MO.isUndef() && "Expected undef machine operand");
// We can't change registers that aren't renamable.
if (!MO.isRenamable())
return false;
Register OriginalReg = MO.getReg();
// Update only undef operands that have reg units that are mapped to one root.