[PATCH] D42292: [ARM] Call __chkstk for dynamic stack allocation in all windows environments

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 04:20:56 PST 2018


mstorsjo created this revision.
mstorsjo added reviewers: rnk, compnerd.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

This matches what MSVC does for alloca() function calls on ARM. Even if MSVC doesn't support VLAs at the language level, it does support the alloca function.


Repository:
  rL LLVM

https://reviews.llvm.org/D42292

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/Windows/alloca.ll
  test/CodeGen/ARM/Windows/vla.ll


Index: test/CodeGen/ARM/Windows/vla.ll
===================================================================
--- test/CodeGen/ARM/Windows/vla.ll
+++ test/CodeGen/ARM/Windows/vla.ll
@@ -3,7 +3,7 @@
 ; RUN: llc -mtriple=thumbv7-windows-itanium -mcpu=cortex-a9 -code-model=large -o - %s \
 ; RUN:  | FileCheck %s -check-prefix CHECK-LARGE-CODE
 ; RUN: llc -mtriple=thumbv7-windows-msvc -mcpu=cortex-a9 -o - %s \
-; RUN:  | FileCheck %s -check-prefix CHECK-MSVC
+; RUN:  | FileCheck %s -check-prefix CHECK-SMALL-CODE
 
 define arm_aapcs_vfpcc i8 @function(i32 %sz, i32 %idx) {
 entry:
@@ -26,6 +26,3 @@
 ; CHECK-LARGE-CODE:   movt  [[IP]], :upper16:__chkstk
 ; CHECK-LARGE-CODE:   blx   [[IP]]
 ; CHECK-LARGE-CODE:   sub.w sp, sp, r4
-
-; CHECK-MSVC-NOT: __chkstk
-
Index: test/CodeGen/ARM/Windows/alloca.ll
===================================================================
--- test/CodeGen/ARM/Windows/alloca.ll
+++ test/CodeGen/ARM/Windows/alloca.ll
@@ -1,4 +1,6 @@
 ; RUN: llc -O0 -mtriple thumbv7-windows-itanium -filetype asm -o - %s | FileCheck %s
+; RUN: llc -O0 -mtriple thumbv7-windows-msvc -filetype asm -o - %s | FileCheck %s
+; RUN: llc -O0 -mtriple thumbv7-windows-mingw32 -filetype asm -o - %s | FileCheck %s
 
 declare arm_aapcs_vfpcc i32 @num_entries()
 
Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -949,7 +949,7 @@
   setOperationAction(ISD::STACKSAVE,          MVT::Other, Expand);
   setOperationAction(ISD::STACKRESTORE,       MVT::Other, Expand);
 
-  if (Subtarget->getTargetTriple().isWindowsItaniumEnvironment())
+  if (Subtarget->getTargetTriple().isOSWindows())
     setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom);
   else
     setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand);
@@ -7956,7 +7956,7 @@
   case ISD::SDIVREM:
   case ISD::UDIVREM:       return LowerDivRem(Op, DAG);
   case ISD::DYNAMIC_STACKALLOC:
-    if (Subtarget->getTargetTriple().isWindowsItaniumEnvironment())
+    if (Subtarget->getTargetTriple().isOSWindows())
       return LowerDYNAMIC_STACKALLOC(Op, DAG);
     llvm_unreachable("Don't know how to custom lower this!");
   case ISD::FP_ROUND: return LowerFP_ROUND(Op, DAG);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42292.130586.patch
Type: text/x-patch
Size: 2296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180119/e86611b4/attachment.bin>


More information about the llvm-commits mailing list