<div dir="ltr">I assumed in that situation all those "spills" with non-overlapping ranges will have been consolidated into a single stack slot? i.e. "the maximum deficit of registers vs live values at any point in execution of the function is one"<div><br></div><div>But I didn't look at the spilling logic.</div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 1, 2017 at 4:31 PM, Daniel Neilson <span dir="ltr"><<a href="mailto:dneilson@azul.com" target="_blank">dneilson@azul.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word">
<div>I think that the “one spill” case might be a little less restrictive than that. If you have N spills, but the live ranges for the spills do not overlap then you could just spill to Y instead of the stack.</div>
<div><br>
</div>
<div>-Daniel</div><div><div class="h5">
<div><br>
</div>
<br>
<div>
<blockquote type="cite">
<div>On May 1, 2017, at 2:19 AM, Bruce Hoult via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div>
<br class="m_-9154647543434975288Apple-interchange-newline">
<div>
<div dir="ltr">Why not do it the other way around?
<div><br>
</div>
<div>Mark Y as reserved, and then at the end of the function if there was exactly one spill then put that variable in Y instead.</div>
<div><br>
</div>
<div>If there were no spills then you lost nothing by reserving Y. If there were more than one then you need Y for this stack adjustment. So exactly one spill is the only case where you lost anything by reserving Y.</div>
<div><br>
</div>
<div>Which is probably pretty rare, to be honest.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, May 1, 2017 at 6:27 AM, Dylan McKay 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">
<div dir="ltr">Hey all,
<div><br>
</div>
<div>I'm attempting to rewrite something that the AVR backend used to support (through an extremely dirty hack that was reverted before the upstreaming of the target).</div>
<div><br>
</div>
<div>The removal of the hack can be seen on GitHub</div>
<div><br>
</div>
<div><a href="https://github.com/avr-llvm/llvm/pull/226/files" target="_blank">https://github.com/avr-llvm/ll<wbr>vm/pull/226/files</a><br>
</div>
<div><br>
</div>
<div>On the AVR architecture, the stack pointer is not in a standard register, but rather it is a special register which can only be accessed via I/O instructions. In order to implement stack spilling/restoring we need to adjust the stack pointer,
 which is a problem because we need the value of SP to be in a general purpose register for us to perform arithmetic on it.</div>
<div><br>
</div>
<div>In AVR-GCC, a frame pointer (the 'Y' register) is reserved if there are any spills in a method. This works fine because we can easily perform arithmetic on it and then save it into the real stack pointer via IO instructions.</div>
<div><br>
</div>
<div>I would like to do the same for LLVM. This is tricky however, because we don't know if we need a frame pointer until we've finished register allocation and we've seen a spill.</div>
<div><br>
</div>
<div>In the event that we do see a spill, it is likely that the 'Y' register has already been allocated to some other variable, and so we somehow need to deallocate it and then rewind the regalloc. That is what the old hack above does.</div>
<div><br>
</div>
<div>Is there any way today I can deallocate a register and rewind allocation upon spilling?</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div>
</blockquote>
</div>
<br>
<br></div></div><span class="HOEnZb"><font color="#888888">-- 
<br>This message has been scanned for viruses and
<br>dangerous content by
<a href="http://www.mailscanner.info/" target="_blank"><b>MailScanner</b></a>, and is
<br>believed to be clean.
</font></span></div>

</blockquote></div><br></div>