85 lines · plain
1; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=WIN_X322; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s -check-prefix=WIN_X643; RUN: llc < %s -mtriple=x86_64-pc-win32 -code-model=large | FileCheck %s -check-prefix=WIN64_LARGE4; RUN: llc < %s -mtriple=x86_64-uefi | FileCheck %s -check-prefix=WIN_X645; RUN: llc < %s -mtriple=x86_64-uefi -code-model=large | FileCheck %s -check-prefix=WIN64_LARGE6; RUN: llc < %s -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X327; RUN: llc < %s -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X648; RUN: llc < %s -mtriple=i386-pc-linux | FileCheck %s -check-prefix=LINUX9; RUN: llc < %s -mtriple=x86_64-pc-win32-macho | FileCheck %s -check-prefix=LINUX10 11; Windows and mingw require a prologue helper routine if more than 4096 bytes area12; allocated on the stack. Windows uses __chkstk and mingw uses __alloca. __alloca13; and the 32-bit version of __chkstk will probe the stack and adjust the stack pointer.14; The 64-bit version of __chkstk is only responsible for probing the stack. The 64-bit15; prologue is responsible for adjusting the stack pointer.16 17; Stack allocation >= 4096 bytes will require call to __chkstk in the Windows ABI.18define i32 @main4k() nounwind {19entry:20; WIN_X32: calll __chkstk21; WIN_X64: callq __chkstk22; WIN64_LARGE: movabsq $__chkstk, %r1123; WIN64_LARGE: callq *%r1124; MINGW_X32: calll __alloca25; MINGW_X64: callq ___chkstk_ms26; LINUX-NOT: call __chkstk27 %array4096 = alloca [4096 x i8], align 16 ; <ptr> [#uses=0]28 ret i32 029}30 31; Make sure we don't call __chkstk or __alloca when we have less than a 4096 stack32; allocation.33define i32 @main128() nounwind {34entry:35; WIN_X32: # %bb.0:36; WIN_X32-NOT: calll __chkstk37; WIN_X32: ret38 39; WIN_X64: # %bb.0:40; WIN_X64-NOT: callq __chkstk41; WIN_X64: ret42 43; MINGW_X64: # %bb.0:44; MINGW_X64-NOT: callq ___chkstk_ms45; MINGW_X64: ret46 47; LINUX: # %bb.0:48; LINUX-NOT: call __chkstk49; LINUX: ret50 %array128 = alloca [128 x i8], align 16 ; <ptr> [#uses=0]51 ret i32 052}53 54; Make sure we don't call __chkstk or __alloca on non-Windows even if the55; caller has the Win64 calling convention.56define win64cc i32 @main4k_win64() nounwind {57entry:58; WIN_X32: calll __chkstk59; WIN_X64: callq __chkstk60; WIN64_LARGE: movabsq $__chkstk, %r1161; WIN64_LARGE: callq *%r1162; MINGW_X32: calll __alloca63; MINGW_X64: callq ___chkstk_ms64; LINUX-NOT: call __chkstk65 %array4096 = alloca [4096 x i8], align 16 ; <ptr> [#uses=0]66 ret i32 067}68 69; PR30687: Avoid crashing when inserting a __chkstk call at the end of an MBB.70define void @dont_crash() {71entry:72; WIN_X32: calll __chkstk73; WIN_X64: callq __chkstk74; WIN64_LARGE: movabsq $__chkstk, %r1175; WIN64_LARGE: callq *%r1176; MINGW_X32: calll __alloca77; MINGW_X64: callq ___chkstk_ms78; LINUX-NOT: call __chkstk79 %buffer = alloca [4096 x i8]80 br label %ret81 82ret:83 ret void84}85