Does this fix PR331?
-Chris On Tue, 13 Jun 2006, Evan Cheng wrote:
Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.157 -> 1.158 --- Log message: Cygwin support: use _alloca to allocate stack if > 4k. Patch by Anton Korobeynikov. --- Diffs of the changes: (+21 -4) X86RegisterInfo.cpp | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.157 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.158 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.157 Tue Jun 6 18:30:24 2006 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Tue Jun 13 00:14:44 2006 @@ -740,7 +740,7 @@ const Function* Fn = MF.getFunction(); const X86Subtarget* Subtarget = &MF.getTarget().getSubtarget<X86Subtarget>(); MachineInstr *MI; - + // Get the number of bytes to allocate from the FrameInfo unsigned NumBytes = MFI->getStackSize(); if (MFI->hasCalls() || MF.getFrameInfo()->hasVarSizedObjects()) { @@ -760,9 +760,20 @@ MFI->setStackSize(NumBytes); if (NumBytes) { // adjust stack pointer: ESP -= numbytes - unsigned Opc = NumBytes < 128 ? X86::SUB32ri8 : X86::SUB32ri; - MI = BuildMI(Opc, 1, X86::ESP,MachineOperand::UseAndDef).addImm(NumBytes); - MBB.insert(MBBI, MI); + if (NumBytes >= 4096 && Subtarget->TargetType == X86Subtarget::isCygwin) { + // Function prologue calls _alloca to probe the stack when allocating + // more than 4k bytes in one go. Touching the stack at 4K increments is + // necessary to ensure that the guard pages used by the OS virtual memory + // manager are allocated in correct sequence. + MI = BuildMI(X86::MOV32ri, 2, X86::EAX).addImm(NumBytes); + MBB.insert(MBBI, MI); + MI = BuildMI(X86::CALLpcrel32, 1).addExternalSymbol("_alloca"); + MBB.insert(MBBI, MI); + } else { + unsigned Opc = NumBytes < 128 ? X86::SUB32ri8 : X86::SUB32ri; + MI = BuildMI(Opc, 1, X86::ESP,MachineOperand::UseAndDef).addImm(NumBytes); + MBB.insert(MBBI, MI); + } } if (hasFP(MF)) { @@ -789,6 +800,12 @@ Subtarget->TargetType == X86Subtarget::isCygwin) { MI = BuildMI(X86::AND32ri, 2, X86::ESP).addImm(-Align); MBB.insert(MBBI, MI); + + // Probe the stack + MI = BuildMI(X86::MOV32ri, 2, X86::EAX).addImm(Align); + MBB.insert(MBBI, MI); + MI = BuildMI(X86::CALLpcrel32, 1).addExternalSymbol("_alloca"); + MBB.insert(MBBI, MI); } } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-Chris -- http://nondot.org/sabre/ http://llvm.org/ _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits