<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 11/30/2012 6:36 PM, Lang Hames
wrote:<br>
</div>
<blockquote
cite="mid:CALLttgqJSP_O5-Wo=9CJHuqZAjaN-wxT49qbSjer_keHAZSeqQ@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
<br>
<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>
</blockquote>
<blockquote
cite="mid:CALLttgqJSP_O5-Wo=9CJHuqZAjaN-wxT49qbSjer_keHAZSeqQ@mail.gmail.com"
type="cite">
<div>If it doesn't already, your allocator should filter out
reserved registers (See MachineRegisterInfo::isReserved(unsigned
preg)) when assigning physregs.</div>
</blockquote>
<br>
I AM filtering out reserved registers. <br>
<br>
I am not allocating RBP in function bar, I am allocating EBP,
because it is NOT in the list of reserved registers for function
bar.<br>
<br>
Neither register RBP nor register EBP is saved/restored across the
call from foo to bar, either by the code for the call or the code
for entry to bar.<br>
<br>
The input C file that is causing this problem is flex.c (attached).
The calling function is "yyparse" and the called function is
"scinstal".<br>
<br>
Here are the reserved registers for yyparse: { 7 44 54 106 111 114
118 }<br>
<br>
Here are the reserved registers for scinstal: { 54 111 114 }<br>
<br>
Register EBP is preg 44, which is NOT in the reserved list for
scinstal (nor is it an alias of any of those reserved registers; the
aliases are { 50 64 117 118 }). I don;t know which preg
corresponds to RBP.<br>
<br>
You say that RBP should be saved/restored across the call. I tried
to generate that code, but, as I said in my previous mail, I don't
know how to get the appropriate TargetRegisterClass (needed to call
CreateSpillStackObject). Should I instead be generating code to
save register EBP at the start of scinstal, restoring it at the end
of that function?<br>
<br>
Susan<br>
<br>
<blockquote
cite="mid:CALLttgqJSP_O5-Wo=9CJHuqZAjaN-wxT49qbSjer_keHAZSeqQ@mail.gmail.com"
type="cite">
<div><br>
</div>
<div><span>ArrayRef<MCPhysReg> pregs =
TRC->getRawAllocationOrder(&MF);</span></div>
<div><span>for (int i = 0; i < pregs.size(); ++i) {</span></div>
<div><span> if (MRI->isReserved(pregs[i]))</span></div>
<div><span> continue;</span></div>
<div><span> // use preg...</span></div>
<div><span>}</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 moz-do-not-send="true"
href="mailto:horwitz@cs.wisc.edu" target="_blank">horwitz@cs.wisc.edu</a>></span>
wrote:<br>
<blockquote class="gmail_quote">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"><br>
<br>
Susan<br>
</span></blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>