diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineOperand.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineOperand.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index 9122edefac7..409dd079a3c 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -50,6 +50,9 @@ void MachineOperand::setReg(unsigned Reg) { if (getReg() == Reg) return; // No change. + // Clear the IsRenamable bit to keep it conservatively correct. + IsRenamable = false; + // Otherwise, we have to change the register. If this operand is embedded // into a machine function, we need to update the old and new register's // use/def lists. @@ -110,30 +113,27 @@ bool MachineOperand::isRenamable() const { assert(isReg() && "Wrong MachineOperand accessor"); assert(TargetRegisterInfo::isPhysicalRegister(getReg()) && "isRenamable should only be checked on physical registers"); - return IsRenamable; + if (!IsRenamable) + return false; + + const MachineInstr *MI = getParent(); + if (!MI) + return true; + + if (isDef()) + return !MI->hasExtraDefRegAllocReq(MachineInstr::IgnoreBundle); + + assert(isUse() && "Reg is not def or use"); + return !MI->hasExtraSrcRegAllocReq(MachineInstr::IgnoreBundle); } void MachineOperand::setIsRenamable(bool Val) { assert(isReg() && "Wrong MachineOperand accessor"); assert(TargetRegisterInfo::isPhysicalRegister(getReg()) && "setIsRenamable should only be called on physical registers"); - if (const MachineInstr *MI = getParent()) - if ((isDef() && MI->hasExtraDefRegAllocReq()) || - (isUse() && MI->hasExtraSrcRegAllocReq())) - assert(!Val && "isRenamable should be false for " - "hasExtraDefRegAllocReq/hasExtraSrcRegAllocReq opcodes"); IsRenamable = Val; } -void MachineOperand::setIsRenamableIfNoExtraRegAllocReq() { - if (const MachineInstr *MI = getParent()) - if ((isDef() && MI->hasExtraDefRegAllocReq()) || - (isUse() && MI->hasExtraSrcRegAllocReq())) - return; - - setIsRenamable(true); -} - // If this operand is currently a register operand, and if this is in a // function, deregister the operand from the register's use/def list. void MachineOperand::removeRegFromUses() { |