[ms-inline asm] Force the use of a base pointer if the MachineFunction includes
authorChad Rosier <mcrosier@apple.com>
Tue, 19 Feb 2013 23:50:45 +0000 (23:50 +0000)
committerChad Rosier <mcrosier@apple.com>
Tue, 19 Feb 2013 23:50:45 +0000 (23:50 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175576 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86RegisterInfo.cpp
test/CodeGen/X86/ms-inline-asm.ll

index 401eefb16afe5e82cbf069e23e702b1bccf105c7..fbe6331e84591769bc62badc6f04f14c676a31de 100644 (file)
@@ -389,8 +389,10 @@ bool X86RegisterInfo::hasBasePointer(const MachineFunction &MF) const {
      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;
index eca174610dac75784ae69e05d8f87d43727f4aa3..5048a93ad302a57391501d165db86efd987aff10 100644 (file)
@@ -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
 }