diff --git a/include/llvm/CodeGen/RegisterScavenging.h b/include/llvm/CodeGen/RegisterScavenging.h index 458c2e4487f..fc75aea2bcb 100644 --- a/include/llvm/CodeGen/RegisterScavenging.h +++ b/include/llvm/CodeGen/RegisterScavenging.h @@ -113,6 +113,9 @@ 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/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp index 972cf13a240..e32d23264d6 100644 --- a/lib/CodeGen/RegisterScavenging.cpp +++ b/lib/CodeGen/RegisterScavenging.cpp @@ -57,6 +57,14 @@ static bool RedefinesSuperRegPart(const MachineInstr *MI, return RedefinesSuperRegPart(MI, MO.getReg(), TRI); } +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); @@ -218,7 +226,7 @@ void RegScavenger::forward() { const MachineOperand MO = *UseMOs[i].first; unsigned Reg = MO.getReg(); - assert(isUsed(Reg) && "Using an undefined register!"); + assert((MO.isImplicit() || isUsed(Reg)) && "Using an undefined register!"); if (MO.isKill() && !isReserved(Reg)) { KillRegs.set(Reg); @@ -269,7 +277,8 @@ void RegScavenger::forward() { // Implicit def is allowed to "re-define" any register. Similarly, // implicitly defined registers can be clobbered. - assert((isReserved(Reg) || isUnused(Reg) || + assert((MO.isImplicit() || isReserved(Reg) || isUnused(Reg) || + isSuperRegUsed(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"); setUsed(Reg); diff --git a/test/CodeGen/Blackfin/load-intr.ll b/test/CodeGen/Blackfin/load-intr.ll index 9d742370228..9ef8b978aca 100644 --- a/test/CodeGen/Blackfin/load-intr.ll +++ b/test/CodeGen/Blackfin/load-intr.ll @@ -1,7 +1,4 @@ ; RUN: llvm-as < %s | llc -march=bfin -verify-machineinstrs | FileCheck %s -; XFAIL: * -; Assertion failed: (isUsed(Reg) && "Using an undefined register!"), -; function forward, file lib/CodeGen/RegisterScavenging.cpp, line 221. define i16 @f(i32* %p) nounwind { entry: