[LLVMdev] Heads up: Local register allocator going away

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jun 4 09:55:57 PDT 2010

On Jun 4, 2010, at 3:05 AM, Sylvere Teissier wrote:
> In my target the CALL instruction change the link Register %LR
> In the target InstrInfo.td I have "Defs=[LR]" on the CALL instruction
> definition to handle that.

So your CALL instructions are clobbering your callee-saved registers, eh? ;-)

> It works well with others registers allocators: when there is a call
> they mark LR used in the function with MRI->addPhysRegsUsed(UsedInInstr);
> and LR is callee saved correctly during prolog/epilog insertion.
> But with fast register allocator the following lines ignore the Def on
> LR in the call instruction: (line 747)
> if (TID.isCall()) {
> // Spill all virtregs before a call. This serves two purposes: 1. If an
> // exception is thrown, the landing pad is going to expect to find registers
> // in their spill slots, and 2. we don't have to wade through all the
> // <imp-def> operands on the call instruction.
>  DefOpEnd = VirtOpEnd;
>  DEBUG(dbgs() << "  Spilling remaining registers before call.\n");
>  spillAll(MI);
> }
> if I remove this block this fix the bug: LR is marked used with
> MRI->addPhysRegsUsed(UsedInInstr)
> and LR is correctly saved and restored in the function prolog/epilog.
> Is this code really usefull ? :D

Yes, calls can have ridiculously long lists of clobbered registers that we really don't want to go through in a 'fast' allocator. 

But you are right, those registers still need to be marked as used by the function.

I'll fix it, thanks!


More information about the llvm-dev mailing list