<div dir="ltr">Note that it would be very unusual to have no callee saved registers.<div><br></div><div>Historically (pre-RISC), it was normal to pass arguments on the stack and have ALL registers callee saved. Or maybe to have just one or two registers that could be clobbered by the called function, or linkage code.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 1, 2015 at 7:01 PM, Peter Bergner via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, 2015-09-01 at 08:52 -0700, Jacques Pienaar via llvm-dev wrote:<br>
<br>
> int main() {<br>
>   for (int i = 0; i < 10; ++i) {<br>
>     foo();<br>
>   }<br>
> }<br>
><br>
><br>
> The resultant output code spills 'i' within the loop (I have to<br>
</span>> compile with -fno-unroll-loops else the loop and 'i' gets optimi! zed<br>
<span class="">> away) while 'i' is assigned to a register that is used nowhere else in<br>
> the generated program and I would consider 'foo' easy to analyse. At<br>
> the call site of 'foo' the debugging output reports that the stack<br>
> pointer and return value registers are "imp-use" and "imp-def" and no<br>
> other registers are used.<br>
<br>
</span>When a function (such as main() in this case) is compiled, all calls to<br>
functions are assumed to clobber all caller saved registers.  Since your<br>
backend said that all registers are caller saved, then the compiler has<br>
not choice but to spill 'i' around the call to foo(), since it may<br>
trash the register 'i' is allocated to.<br>
<span class=""><br>
<br>
> Should the spilling have occurred? Or this due to some feature in the<br>
> backend that is missing?<br>
<br>
</span>This is totally as expected when you have no callee saved registers.<br>
<br>
<br>
Peter<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>