[llvm] r175576 - [ms-inline asm] Force the use of a base pointer if the MachineFunction includes

Reid Kleckner rnk at google.com
Wed Aug 7 17:17:03 PDT 2013


On Wed, Aug 7, 2013 at 4:46 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk>wrote:

>
> On Aug 7, 2013, at 4:40 PM, Reid Kleckner <rnk at google.com> wrote:
>
> > In retrospect, I don't think this is right, since it miscompiles LLVM's
> own cpuid call in Host.cpp:
> > http://llvm.org/bugs/show_bug.cgi?id=16830
> >
> > Chad, can you (or anyone else) elaborate on the conditions under which
> the frame pointer might not be used to reference the local variable?
>
> 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.
>
> When the function contains dynamic allocas, the stack pointer can’t be
> used to access local objects.


Then the logic should be:
   if (needsStackRealignment(MF) && (MFI->hasVarSizedObjects()
|| MF.hasMSInlineAsm()))
     return true;

There'd still a bug in the case where we need stack realignment and we have
MS inline asm that clobbers esi.

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130807/09faac12/attachment.html>


More information about the llvm-commits mailing list