Calling _chkstk is required on ELF as well as COFF on Windows.

Without _chkstk functions requiring large stack crash in 
initialization code. Previous code tested for COFF format but 
not Mach-O and this patch modifies the code to test for Windows.

Credits to Andrew MacPherson.

llvm-svn: 193263
This commit is contained in:
Yaron Keren 2013-10-23 19:40:07 +00:00
parent da8446b833
commit 03ac82edf5
3 changed files with 4 additions and 2 deletions

View File

@ -606,7 +606,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
// responsible for adjusting the stack pointer. Touching the stack at 4K // responsible for adjusting the stack pointer. Touching the stack at 4K
// increments is necessary to ensure that the guard pages used by the OS // increments is necessary to ensure that the guard pages used by the OS
// virtual memory manager are allocated in correct sequence. // virtual memory manager are allocated in correct sequence.
if (NumBytes >= 4096 && STI.isTargetCOFF() && !STI.isTargetEnvMacho()) { if (NumBytes >= 4096 && STI.isOSWindows()) {
const char *StackProbeSymbol; const char *StackProbeSymbol;
bool isSPUpdateNeeded = false; bool isSPUpdateNeeded = false;

View File

@ -631,7 +631,7 @@ void X86TargetLowering::resetOperationActions() {
setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho()) if (Subtarget->isTargetWindows())
setOperationAction(ISD::DYNAMIC_STACKALLOC, Subtarget->is64Bit() ? setOperationAction(ISD::DYNAMIC_STACKALLOC, Subtarget->is64Bit() ?
MVT::i64 : MVT::i32, Custom); MVT::i64 : MVT::i32, Custom);
else if (TM.Options.EnableSegmentedStacks) else if (TM.Options.EnableSegmentedStacks)

View File

@ -333,6 +333,8 @@ public:
} }
bool isTargetEnvMacho() const { return TargetTriple.isEnvironmentMachO(); } bool isTargetEnvMacho() const { return TargetTriple.isEnvironmentMachO(); }
bool isOSWindows() const { return TargetTriple.isOSWindows(); }
bool isTargetWin64() const { bool isTargetWin64() const {
return In64BitMode && TargetTriple.isOSWindows(); return In64BitMode && TargetTriple.isOSWindows();
} }