Scavenger asserts.

Allow imp-def and imp-use of anything in the scavenger asserts, just like the machine code verifier.
Allow redefinition of a sub-register of a live register.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2009-08-02 18:28:41 +00:00
parent 6b30f5c867
commit 0e6a4efdd4
3 changed files with 14 additions and 5 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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: