diff options
-rw-r--r-- | include/llvm/CodeGen/RegisterScavenging.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/LowerSubregs.cpp | 13 | ||||
-rw-r--r-- | lib/CodeGen/RegisterScavenging.cpp | 34 |
3 files changed, 9 insertions, 41 deletions
diff --git a/include/llvm/CodeGen/RegisterScavenging.h b/include/llvm/CodeGen/RegisterScavenging.h index 478da3d..2b86e5f 100644 --- a/include/llvm/CodeGen/RegisterScavenging.h +++ b/include/llvm/CodeGen/RegisterScavenging.h @@ -112,9 +112,6 @@ public: bool isUsed(unsigned Reg) const { return !RegsAvailable[Reg]; } bool isUnused(unsigned Reg) const { return RegsAvailable[Reg]; } - /// isSuperRegUsed - Test if a super register is currently being used. - bool isSuperRegUsed(unsigned Reg) const; - /// getRegsUsed - return all registers currently in use in used. void getRegsUsed(BitVector &used, bool includeReserved); diff --git a/lib/CodeGen/LowerSubregs.cpp b/lib/CodeGen/LowerSubregs.cpp index 6c5052a..f34b290 100644 --- a/lib/CodeGen/LowerSubregs.cpp +++ b/lib/CodeGen/LowerSubregs.cpp @@ -270,14 +270,15 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) { MachineBasicBlock::iterator CopyMI = MI; --CopyMI; + // INSERT_SUBREG is a two-address instruction so it implicitly kills SrcReg. + if (!MI->getOperand(1).isUndef()) + CopyMI->addOperand(MachineOperand::CreateReg(DstReg, false, true, true)); + // Transfer the kill/dead flags, if needed. if (MI->getOperand(0).isDead()) { TransferDeadFlag(MI, DstSubReg, TRI); - // Also add a SrcReg<imp-kill> of the super register. - CopyMI->addOperand(MachineOperand::CreateReg(DstReg, false, true, true)); - } else if (MI->getOperand(1).isUndef()) { - // If SrcReg was marked <undef> we must make sure it is alive after this - // replacement. Add a SrcReg<imp-def> operand. + } else { + // Make sure the full DstReg is live after this replacement. CopyMI->addOperand(MachineOperand::CreateReg(DstReg, true, true)); } @@ -293,7 +294,7 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) { DOUT << "\n"; MBB->erase(MI); - return true; + return true; } /// runOnMachineFunction - Reduce subregister inserts and extracts to register diff --git a/lib/CodeGen/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp index bb12556..93c0eb0 100644 --- a/lib/CodeGen/RegisterScavenging.cpp +++ b/lib/CodeGen/RegisterScavenging.cpp @@ -30,35 +30,6 @@ #include "llvm/ADT/STLExtras.h" using namespace llvm; -/// RedefinesSuperRegPart - Return true if the specified register is redefining -/// part of a super-register. -static bool RedefinesSuperRegPart(const MachineInstr *MI, unsigned SubReg, - const TargetRegisterInfo *TRI) { - bool SeenSuperUse = false; - bool SeenSuperDef = false; - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = MI->getOperand(i); - if (!MO.isReg() || MO.isUndef()) - continue; - if (TRI->isSuperRegister(SubReg, MO.getReg())) { - if (MO.isUse()) - SeenSuperUse = true; - else if (MO.isImplicit()) - SeenSuperDef = true; - } - } - - return SeenSuperDef && SeenSuperUse; -} - -bool RegScavenger::isSuperRegUsed(unsigned Reg) const { - for (const unsigned *SuperRegs = TRI->getSuperRegisters(Reg); - unsigned SuperReg = *SuperRegs; ++SuperRegs) - if (isUsed(SuperReg)) - return true; - return false; -} - /// setUsed - Set the register and its sub-registers as being used. void RegScavenger::setUsed(unsigned Reg) { RegsAvailable.reset(Reg); @@ -74,8 +45,7 @@ void RegScavenger::setUnused(unsigned Reg, const MachineInstr *MI) { for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); unsigned SubReg = *SubRegs; ++SubRegs) - if (!RedefinesSuperRegPart(MI, Reg, TRI)) - RegsAvailable.set(SubReg); + RegsAvailable.set(SubReg); } void RegScavenger::initRegState() { @@ -257,7 +227,7 @@ void RegScavenger::forward() { "Using an early clobbered register!"); } else { assert(MO.isDef()); - assert((KillRegs.test(Reg) || isUnused(Reg) || isSuperRegUsed(Reg) || + assert((KillRegs.test(Reg) || isUnused(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"); } |