1; RUN: llc < %s -enable-shrink-wrap=true | FileCheck %s 2 3; chkstk cannot come before the usual prologue, since it adjusts ESP. 4; If chkstk is used in the prologue, we also have to be careful about preserving 5; EAX if it is used. 6 7target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 8target triple = "i686-pc-windows-msvc18.0.0" 9 10%struct.S = type { [8192 x i8] } 11 12define x86_thiscallcc void @call_inalloca(i1 %x) { 13entry: 14 %argmem = alloca inalloca <{ %struct.S }>, align 4 15 %argidx1 = getelementptr inbounds <{ %struct.S }>, <{ %struct.S }>* %argmem, i32 0, i32 0, i32 0, i32 0 16 %argidx2 = getelementptr inbounds <{ %struct.S }>, <{ %struct.S }>* %argmem, i32 0, i32 0, i32 0, i32 1 17 store i8 42, i8* %argidx2, align 4 18 br i1 %x, label %bb1, label %bb2 19 20bb1: 21 store i8 42, i8* %argidx1, align 4 22 br label %bb2 23 24bb2: 25 call void @inalloca_params(<{ %struct.S }>* inalloca nonnull %argmem) 26 ret void 27} 28 29; CHECK-LABEL: _call_inalloca: # @call_inalloca 30; CHECK: pushl %ebp 31; CHECK: movl %esp, %ebp 32; CHECK: movl $8192, %eax 33; CHECK: calll __chkstk 34; CHECK: calll _inalloca_params 35; CHECK: movl %ebp, %esp 36; CHECK: popl %ebp 37; CHECK: retl 38 39declare void @inalloca_params(<{ %struct.S }>* inalloca) 40 41declare i32 @doSomething(i32, i32*) 42 43; In this test case, we force usage of EAX before the prologue, and have to 44; compensate before calling __chkstk. It would also be valid for us to avoid 45; shrink wrapping in this case. 46 47define x86_fastcallcc i32 @use_eax_before_prologue(i32 inreg %a, i32 inreg %b) { 48 %tmp = alloca i32, i32 1024, align 4 49 %tmp2 = icmp slt i32 %a, %b 50 br i1 %tmp2, label %true, label %false 51 52true: 53 store i32 %a, i32* %tmp, align 4 54 %tmp4 = call i32 @doSomething(i32 0, i32* %tmp) 55 br label %false 56 57false: 58 %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ] 59 ret i32 %tmp.0 60} 61 62; CHECK-LABEL: @use_eax_before_prologue@8: # @use_eax_before_prologue 63; CHECK: movl %ecx, %eax 64; CHECK: cmpl %edx, %eax 65; CHECK: jge LBB1_2 66; CHECK: pushl %eax 67; CHECK: movl $4092, %eax 68; CHECK: calll __chkstk 69; CHECK: movl 4092(%esp), %eax 70; CHECK: calll _doSomething 71; CHECK: LBB1_2: 72; CHECK: retl 73