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

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Aug 2 07:31:35 PDT 2009


Hi,

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.

A test case is part of the blackfin patch (addsub-i128.ll).

/jakob




More information about the llvm-commits mailing list