1 ; RUN: llc < %s -enable-shrink-wrap=true | FileCheck %s
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
7 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
8 target triple = "i686-pc-windows-msvc18.0.0"
10 %struct.S = type { [8192 x i8] }
12 define x86_thiscallcc void @call_inalloca(i1 %x) {
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
21 store i8 42, i8* %argidx1, align 4
25 call void @inalloca_params(<{ %struct.S }>* inalloca nonnull %argmem)
29 ; CHECK-LABEL: _call_inalloca: # @call_inalloca
31 ; CHECK: movl %esp, %ebp
32 ; CHECK: movl $8192, %eax
33 ; CHECK: calll __chkstk
34 ; CHECK: calll _inalloca_params
35 ; CHECK: movl %ebp, %esp
39 declare void @inalloca_params(<{ %struct.S }>* inalloca)
41 declare i32 @doSomething(i32, i32*)
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.
47 define 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
53 store i32 %a, i32* %tmp, align 4
54 %tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
58 %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]
62 ; CHECK-LABEL: @use_eax_before_prologue@8: # @use_eax_before_prologue
63 ; CHECK: movl %ecx, %eax
64 ; CHECK: cmpl %edx, %ecx
67 ; CHECK: movl $4092, %eax
68 ; CHECK: calll __chkstk
69 ; CHECK: movl 4092(%esp), %eax
70 ; CHECK: calll _doSomething