Calling _chkstk is required on ELF as well as COFF on Windows.
authorYaron Keren <yaron.keren@gmail.com>
Wed, 23 Oct 2013 19:40:07 +0000 (19:40 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Wed, 23 Oct 2013 19:40:07 +0000 (19:40 +0000)
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.

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

lib/Target/X86/X86FrameLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86Subtarget.h

index adcd4f7dedcf3a73a07619bfcf74af5dea84d066..cf4e42785b397262151eef557cd5b4ff4bce13c5 100644 (file)
@@ -606,7 +606,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
   // responsible for adjusting the stack pointer.  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.
-  if (NumBytes >= 4096 && STI.isTargetCOFF() && !STI.isTargetEnvMacho()) {
+  if (NumBytes >= 4096 && STI.isOSWindows()) {
     const char *StackProbeSymbol;
     bool isSPUpdateNeeded = false;
 
index 5f29f4f8ce3cc15bf4726592fb2e36cf4303adda..d74764714f48af5040eb60b7ca03e989a2a5088b 100644 (file)
@@ -631,7 +631,7 @@ void X86TargetLowering::resetOperationActions() {
   setOperationAction(ISD::STACKSAVE,          MVT::Other, Expand);
   setOperationAction(ISD::STACKRESTORE,       MVT::Other, Expand);
 
-  if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho())
+  if (Subtarget->isTargetWindows())
     setOperationAction(ISD::DYNAMIC_STACKALLOC, Subtarget->is64Bit() ?
                        MVT::i64 : MVT::i32, Custom);
   else if (TM.Options.EnableSegmentedStacks)
index fb357c467565bd7efadd6aebcd9688f8e25ad520..dd8c0811ce51aabe6cec8d43f481498b7f1f129d 100644 (file)
@@ -333,6 +333,8 @@ public:
   }
   bool isTargetEnvMacho() const { return TargetTriple.isEnvironmentMachO(); }
 
+  bool isOSWindows() const { return TargetTriple.isOSWindows(); }
+
   bool isTargetWin64() const {
     return In64BitMode && TargetTriple.isOSWindows();
   }