[llvm] r323308 - [ARM] Call __chkstk for dynamic stack allocation in all windows environments

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 22:40:11 PST 2018


Author: mstorsjo
Date: Tue Jan 23 22:40:11 2018
New Revision: 323308

URL: http://llvm.org/viewvc/llvm-project?rev=323308&view=rev
Log:
[ARM] Call __chkstk for dynamic stack allocation in all windows environments

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.

On the clang level, both the _alloca() (when emulating MSVC, which is
what the alloca() function expands to) and __builtin_alloca() builtin
functions, and VLAs, map to the same LLVM IR "alloca" function - so
within LLVM they're not distinguishable from each other.

Differential Revision: https://reviews.llvm.org/D42292

Modified:
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
    llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll
    llvm/trunk/test/CodeGen/ARM/Windows/vla.ll

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=323308&r1=323307&r2=323308&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Jan 23 22:40:11 2018
@@ -949,7 +949,7 @@ ARMTargetLowering::ARMTargetLowering(con
   setOperationAction(ISD::STACKSAVE,          MVT::Other, Expand);
   setOperationAction(ISD::STACKRESTORE,       MVT::Other, Expand);
 
-  if (Subtarget->getTargetTriple().isWindowsItaniumEnvironment())
+  if (Subtarget->isTargetWindows())
     setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom);
   else
     setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand);
@@ -7956,7 +7956,7 @@ SDValue ARMTargetLowering::LowerOperatio
   case ISD::SDIVREM:
   case ISD::UDIVREM:       return LowerDivRem(Op, DAG);
   case ISD::DYNAMIC_STACKALLOC:
-    if (Subtarget->getTargetTriple().isWindowsItaniumEnvironment())
+    if (Subtarget->isTargetWindows())
       return LowerDYNAMIC_STACKALLOC(Op, DAG);
     llvm_unreachable("Don't know how to custom lower this!");
   case ISD::FP_ROUND: return LowerFP_ROUND(Op, DAG);

Modified: llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll?rev=323308&r1=323307&r2=323308&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll Tue Jan 23 22:40:11 2018
@@ -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()
 

Modified: llvm/trunk/test/CodeGen/ARM/Windows/vla.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/Windows/vla.ll?rev=323308&r1=323307&r2=323308&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/vla.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/Windows/vla.ll Tue Jan 23 22:40:11 2018
@@ -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 @@ entry:
 ; CHECK-LARGE-CODE:   movt  [[IP]], :upper16:__chkstk
 ; CHECK-LARGE-CODE:   blx   [[IP]]
 ; CHECK-LARGE-CODE:   sub.w sp, sp, r4
-
-; CHECK-MSVC-NOT: __chkstk
-




More information about the llvm-commits mailing list