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