[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 16:40:46 PDT 2013


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?


On Tue, Feb 19, 2013 at 3:50 PM, Chad Rosier <mcrosier at apple.com> wrote:

> Author: mcrosier
> Date: Tue Feb 19 17:50:45 2013
> New Revision: 175576
>
> URL: http://llvm.org/viewvc/llvm-project?rev=175576&view=rev
> Log:
> [ms-inline asm] Force the use of a base pointer if the MachineFunction
> includes
> MS-style inline assembly.
>
> This is a follow-on to r175334.  Forcing a FP to be emitted doesn't ensure
> it
> will be used.  Therefore, force the base pointer as well.  We now treat MS
> inline assembly in the same way we treat functions with dynamic stack
> realignment and VLAs.  This guarantees the BP will be used to reference
> parameters and locals.
> rdar://13218191
>
> Modified:
>     llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
>     llvm/trunk/test/CodeGen/X86/ms-inline-asm.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=175576&r1=175575&r2=175576&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Tue Feb 19 17:50:45 2013
> @@ -389,8 +389,10 @@ bool X86RegisterInfo::hasBasePointer(con
>       return false;
>
>     // When we need stack realignment and there are dynamic allocas, we
> can't
> -   // reference off of the stack pointer, so we reserve a base pointer.
> -   if (needsStackRealignment(MF) && MFI->hasVarSizedObjects())
> +   // reference off of the stack pointer, so we reserve a base pointer.
>  This
> +   // is also true if the function contain MS-style inline assembly.
> +   if ((needsStackRealignment(MF) && MFI->hasVarSizedObjects()) ||
> +       MF.hasMSInlineAsm())
>       return true;
>
>     return false;
>
> Modified: llvm/trunk/test/CodeGen/X86/ms-inline-asm.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ms-inline-asm.ll?rev=175576&r1=175575&r2=175576&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/ms-inline-asm.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/ms-inline-asm.ll Tue Feb 19 17:50:45 2013
> @@ -103,8 +103,8 @@ entry:
>  ; CHECK: {{## InlineAsm End|#NO_APP}}
>  ; CHECK: {{## InlineAsm Start|#APP}}
>  ; CHECK: .intel_syntax
> -; CHECK: mov dword ptr [ebp - 8], edi
> +; CHECK: mov dword ptr [esi], edi
>  ; CHECK: .att_syntax
>  ; CHECK: {{## InlineAsm End|#NO_APP}}
> -; CHECK: movl -8(%ebp), %eax
> +; CHECK: movl (%esi), %eax
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130807/e8475535/attachment.html>


More information about the llvm-commits mailing list