mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
Emit a proper error message when register allocators run out of registers.
This can't be just an assertion, users can always write impossible inline assembly. Such an assembly statement should be included in the error message. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131024 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -321,6 +321,23 @@ void RegAllocBase::allocatePhysRegs() {
|
||||
VirtRegVec SplitVRegs;
|
||||
unsigned AvailablePhysReg = selectOrSplit(*VirtReg, SplitVRegs);
|
||||
|
||||
if (AvailablePhysReg == ~0u) {
|
||||
// selectOrSplit failed to find a register!
|
||||
std::string msg;
|
||||
raw_string_ostream Msg(msg);
|
||||
Msg << "Ran out of registers during register allocation!"
|
||||
"\nCannot allocate: " << *VirtReg;
|
||||
for (MachineRegisterInfo::reg_iterator I = MRI->reg_begin(VirtReg->reg);
|
||||
MachineInstr *MI = I.skipInstruction();) {
|
||||
if (!MI->isInlineAsm())
|
||||
continue;
|
||||
Msg << "\nPlease check your inline asm statement for "
|
||||
"invalid constraints:\n";
|
||||
MI->print(Msg, &VRM->getMachineFunction().getTarget());
|
||||
}
|
||||
report_fatal_error(Msg.str());
|
||||
}
|
||||
|
||||
if (AvailablePhysReg)
|
||||
assign(*VirtReg, AvailablePhysReg);
|
||||
|
||||
@@ -498,8 +515,11 @@ unsigned RABasic::selectOrSplit(LiveInterval &VirtReg,
|
||||
// Tell the caller to allocate to this newly freed physical register.
|
||||
return *PhysRegI;
|
||||
}
|
||||
|
||||
// No other spill candidates were found, so spill the current VirtReg.
|
||||
DEBUG(dbgs() << "spilling: " << VirtReg << '\n');
|
||||
if (!VirtReg.isSpillable())
|
||||
return ~0u;
|
||||
LiveRangeEdit LRE(VirtReg, SplitVRegs);
|
||||
spiller().spill(LRE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user