diff options
| author | Reid Kleckner <reid@kleckner.net> | 2013-12-10 05:31:27 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2013-12-10 05:31:27 +0000 |
| commit | 0a9509f0806b803be1693fef246b3a825d3721c7 (patch) | |
| tree | ee0249862532b9fed79ce55dc5be61b1ee431e1c /llvm/lib/Target | |
| parent | 2f47acfd6a3a17c7d0d0c5b5007bdac5a55e31e8 (diff) | |
| download | bcm5719-llvm-0a9509f0806b803be1693fef246b3a825d3721c7.tar.gz bcm5719-llvm-0a9509f0806b803be1693fef246b3a825d3721c7.zip | |
Revert "Fix miscompile of MS inline assembly with stack realignment"
This reverts commit r196876. Its tests failed on the bots, so I'll
figure it out tomorrow.
llvm-svn: 196879
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/X86/X86FrameLowering.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86RegisterInfo.cpp | 27 |
2 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index 0d76534711d..a06ba9d750a 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -50,7 +50,7 @@ bool X86FrameLowering::hasFP(const MachineFunction &MF) const { return (MF.getTarget().Options.DisableFramePointerElim(MF) || RegInfo->needsStackRealignment(MF) || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken() || MFI->hasInlineAsmWithSPAdjust() || + MFI->isFrameAddressTaken() || MF.hasMSInlineAsm() || MF.getInfo<X86MachineFunctionInfo>()->getForceFramePointer() || MMI.callsUnwindInit() || MMI.callsEHReturn()); } diff --git a/llvm/lib/Target/X86/X86RegisterInfo.cpp b/llvm/lib/Target/X86/X86RegisterInfo.cpp index d3d05cd83a4..dbda556b1b5 100644 --- a/llvm/lib/Target/X86/X86RegisterInfo.cpp +++ b/llvm/lib/Target/X86/X86RegisterInfo.cpp @@ -347,12 +347,6 @@ BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const { "Stack realignment in presence of dynamic allocas is not supported with" "this calling convention."); - // FIXME: Do a proper analysis of the inline asm to see if it actually - // conflicts with the base register we chose. - if (MF.hasInlineAsm()) - report_fatal_error("Stack realignment in presence of dynamic stack " - "adjustments is not supported with inline assembly."); - for (MCSubRegIterator I(getBaseRegister(), this, /*IncludeSelf=*/true); I.isValid(); ++I) Reserved.set(*I); @@ -409,15 +403,18 @@ bool X86RegisterInfo::hasBasePointer(const MachineFunction &MF) const { if (!EnableBasePointer) return false; - // When we need stack realignment, we can't address the stack from the frame - // pointer. When we have dynamic allocas or stack-adjusting inline asm, we - // can't address variables from the stack pointer. MS inline asm can - // reference locals while also adjusting the stack pointer. When we can't - // use both the SP and the FP, we need a separate base pointer register. - bool CantUseFP = needsStackRealignment(MF); - bool CantUseSP = - MFI->hasVarSizedObjects() || MFI->hasInlineAsmWithSPAdjust(); - return CantUseFP && CantUseSP; + // 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. + // + // This is also true if the function contain MS-style inline assembly. We + // do this because if any stack changes occur in the inline assembly, e.g., + // "pusha", then any C local variable or C argument references in the + // inline assembly will be wrong because the SP is not properly tracked. + if ((needsStackRealignment(MF) && MFI->hasVarSizedObjects()) || + MF.hasMSInlineAsm()) + return true; + + return false; } bool X86RegisterInfo::canRealignStack(const MachineFunction &MF) const { |

