<div dir="ltr">On Wed, Aug 7, 2013 at 4:46 PM, Jakob Stoklund Olesen <span dir="ltr"><<a href="mailto:stoklund@2pi.dk" target="_blank">stoklund@2pi.dk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><br>
On Aug 7, 2013, at 4:40 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
<br>
> In retrospect, I don't think this is right, since it miscompiles LLVM's own cpuid call in Host.cpp:<br>
> <a href="http://llvm.org/bugs/show_bug.cgi?id=16830" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=16830</a><br>
><br>
> Chad, can you (or anyone else) elaborate on the conditions under which the frame pointer might not be used to reference the local variable?<br>
<br>
</div>When the function prolog needs to realign the stack, the frame pointer is used to hold the original incoming stack pointer which isn’t aligned. This means that the frame pointer can’t be used to access local objects.<br>

<br>
When the function contains dynamic allocas, the stack pointer can’t be used to access local objects.</blockquote><div><br></div><div>Then the logic should be:</div><div>   if (needsStackRealignment(MF) && (MFI->hasVarSizedObjects() || MF.hasMSInlineAsm()))</div>
<div>     return true;</div></div><br></div><div class="gmail_extra">There'd still a bug in the case where we need stack realignment and we have MS inline asm that clobbers esi.</div><div class="gmail_extra"><br></div>
<div class="gmail_extra">Wouldn't it be much better to use ebp for the base pointer and put the pre-alignment SP into a local that could be spilled or register allocated as necessary?  Is that just a matter of work?</div>
</div>