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

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Aug 2 12:01:15 PDT 2009


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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: scavenger-csr.patch
Type: application/octet-stream
Size: 1845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090802/5d1c5cda/attachment.obj>
-------------- next part --------------



More information about the llvm-commits mailing list