diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-09-26 00:13:34 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-09-26 00:13:34 +0000 |
commit | 29be8486e3cf719c8173635b5ee734c4e414e0af (patch) | |
tree | 691e13635d807bc697c9fd482d8d00c28fc4a059 | |
parent | 9f711252f5d5ef4e05f5277ab462bf7668b53cfd (diff) | |
download | external_llvm-29be8486e3cf719c8173635b5ee734c4e414e0af.zip external_llvm-29be8486e3cf719c8173635b5ee734c4e414e0af.tar.gz external_llvm-29be8486e3cf719c8173635b5ee734c4e414e0af.tar.bz2 |
Correctly restore stack pointer after realignment in main() on Cygwin/Mingw32
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42332 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86RegisterInfo.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index f7cd84f..1fdee67 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -1545,7 +1545,9 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { void X86RegisterInfo::emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); + const Function* Fn = MF.getFunction(); X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>(); + const X86Subtarget* Subtarget = &MF.getTarget().getSubtarget<X86Subtarget>(); MachineBasicBlock::iterator MBBI = prior(MBB.end()); unsigned RetOpcode = MBBI->getOpcode(); @@ -1602,7 +1604,12 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF, // If dynamic alloca is used, then reset esp to point to the last // callee-saved slot before popping them off! - if (MFI->hasVarSizedObjects()) { + // Also, if it's main() on Cygwin/Mingw32 we aligned stack in the prologue, - revert + // stack changes back. Note: we're assuming, that frame pointer was forced + // for main() + if (MFI->hasVarSizedObjects() || + (Fn->hasExternalLinkage() && Fn->getName() == "main" && + Subtarget->isTargetCygMing())) { unsigned Opc = Is64Bit ? X86::LEA64r : X86::LEA32r; if (CSSize) { MachineInstr *MI = addRegOffset(BuildMI(TII.get(Opc), StackPtr), |