Hi Susan,<div><br></div><div>RBP is used as the frame pointer on x86 (hence its automatic appearance in your code), and shouldn't be allocated to any vreg in function bar. Loading/saving RBP should be managed by the stack frame setup/teardown code.</div>
<div><br></div><div>If it doesn't already, your allocator should filter out reserved registers (See MachineRegisterInfo::isReserved(unsigned preg)) when assigning physregs.</div><div><br></div><div><span style="color:rgb(0,0,0);font-size:13px;text-align:-webkit-right;background-color:rgb(250,250,250)"><font face="courier new, monospace">ArrayRef<MCPhysReg> pregs = TRC->getRawAllocationOrder(&MF);</font></span></div>
<div><span style="color:rgb(0,0,0);font-size:13px;text-align:-webkit-right;background-color:rgb(250,250,250)"><font face="courier new, monospace">for (int i = 0; i < pregs.size(); ++i) {</font></span></div><div><span style="color:rgb(0,0,0);font-size:13px;text-align:-webkit-right;background-color:rgb(250,250,250)"><font face="courier new, monospace">  if (MRI->isReserved(pregs[i]))</font></span></div>
<div><span style="color:rgb(0,0,0);font-size:13px;text-align:-webkit-right;background-color:rgb(250,250,250)"><font face="courier new, monospace">    continue;</font></span></div><div><span style="color:rgb(0,0,0);font-size:13px;text-align:-webkit-right;background-color:rgb(250,250,250)"><font face="courier new, monospace">  // use preg...</font></span></div>
<div><span style="color:rgb(0,0,0);font-size:13px;text-align:-webkit-right;background-color:rgb(250,250,250)"><font face="courier new, monospace">}</font></span></div><div><br></div><div>You could also use the AllocationOrder class to simplify the task of finding valid pregs, though it does require you to use VirtRegMap. </div>
<div><br></div><div>If you are already checking the reserved regs then I've misdiagnosed the problem. I'd be happy to dig further if you can point me to a copy of your allocator and a test case.</div><div><br></div>
<div>Cheers,</div><div>Lang.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 29, 2012 at 3:49 PM, Susan Horwitz <span dir="ltr"><<a href="mailto:horwitz@cs.wisc.edu" target="_blank">horwitz@cs.wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a new problem: Register RBP is used in a function foo.  (I am not allocating RBP to any virtual register, the instances of RBP in function foo are in the machine code when my register allocator starts.)<br>

<br>
Function foo calls function bar.  Register RBP is not saved across the call, though it is live after the call.  Function bar includes a virtual register.  The code that I'm using to find the registers available to be allocated to that virtual register includes EBP in that available-preg set.  This is a disaster, since writing into EBP clobbers RBP.<br>

<br>
I tried to add code to save all live physical registers across calls, but I don't know how to get the appropriate TargetRegisterClass (needed to call CreateSpillStackObject).<br>
<br>
Is there a different way to save/restore RBP across calls?  Or a way to get its TargetRegisterClass?<span class="HOEnZb"><font color="#888888"><br>
<br>
Susan<br>
</font></span></blockquote></div><br></div>