[llvm-commits] [PATCH] Scavenging callee-saved registers

Evan Cheng evan.cheng at apple.com
Sun Aug 2 13:00:05 PDT 2009


On Aug 2, 2009, at 12:01 PM, Jakob Stoklund Olesen wrote:

>
> On 02/08/2009, at 20.50, Evan Cheng wrote:
>>> I found an issue with the regscavenger when trying to scavenge a
>>> callee-saved register.
>>>
>>> 1. You need a Goldilocks-sized function: Big enough to use all the
>>> scratch registers, but not big enough to use all the callee-saved
>>> registers.
>>> 2. Wait until insertCSRSpillsAndRestores() has run.
>>> 3. Call RegScavenger::FindUnusedReg(..., ExCalleeSaved=true), get  
>>> a 0
>>> 3. Call RegScavenger::scavengeRegister(). It finds one of the unused
>>> CSRs
>>>
>>> This is all good, scavengeRegister() has saved the CSR to the
>>> emergency spill slot. The problem is that it still considers the CSR
>>> unused, so it asserts when forward() reaches the emergency spill
>>> store. "Using an undefined register!".
>>>
>>> I have attached a patch that fixes this problem. I mark the  
>>> scavenged
>>> register as used to fix the assertion. I also mark the register as
>>> live-in to MBB. That keeps the machine code verifier quiet, but it  
>>> is
>>> a bit of a hack.
>>
>> Ok. Can you attach the patch? :-)
>
> I am a fool. At least now I can un-XFAIL the relevant Blackfin test  
> case. :-)
>
> I noticed that ARM tries to predict this situation so an extra CSR  
> can be spilled. That probably means that ARM will never meet this  
> situation. Unless it guesses wrong for some reason. Blackfin is not  
> so advanced yet. It cannot predict scavenger use.

Looks good. Please commit.

I have a plan to completely revamp the use of register scavenger.  
Basically I want PEI to introduce virtual registers instead of  
scavenging. At the end of PEI it will do another round register  
allocation using the scavenger.

Evan

>
>
> <scavenger-csr.patch>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list