Fix issue in regscavenger when scavenging a callee-saved register that has not been spilled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77912 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2009-08-02 20:29:41 +00:00
parent 7b4e503cdc
commit b36eb9df20
2 changed files with 11 additions and 4 deletions

View File

@ -471,9 +471,16 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC,
Reg = Candidates.find_next(Reg);
}
assert(ScavengedReg == 0 &&
assert(ScavengedReg == 0 &&
"Scavenger slot is live, unable to scavenge another register!");
// Make sure SReg is marked as used. It could be considered available if it is
// one of the callee saved registers, but hasn't been spilled.
if (!isUsed(SReg)) {
MBB->addLiveIn(SReg);
setUsed(SReg);
}
// Spill the scavenged register before I.
TII->storeRegToStackSlot(*MBB, I, SReg, true, ScavengingFrameIndex, RC);
MachineBasicBlock::iterator II = prior(I);

View File

@ -1,7 +1,7 @@
; RUN: llvm-as < %s | llc -march=bfin -verify-machineinstrs
; XFAIL: *
; Assertion failed: (isUsed(Reg) && "Using an undefined register!"),
; function forward, file RegisterScavenging.cpp, line 182.
; These functions have just the right size to annoy the register scavenger: They
; use all the scratch registers, but not all the callee-saved registers.
define void @test_add(i64 %AL, i64 %AH, i64 %BL, i64 %BH, i64* %RL, i64* %RH) {
entry: