2015-12-04 04:46:59 +08:00
|
|
|
; RUN: llc < %s -enable-shrink-wrap=true | FileCheck %s
|
|
|
|
|
|
|
|
; chkstk cannot come before the usual prologue, since it adjusts ESP.
|
2016-02-17 08:17:33 +08:00
|
|
|
; If chkstk is used in the prologue, we also have to be careful about preserving
|
|
|
|
; EAX if it is used.
|
2015-12-04 04:46:59 +08:00
|
|
|
|
|
|
|
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
|
|
|
|
target triple = "i686-pc-windows-msvc18.0.0"
|
|
|
|
|
2016-05-19 00:10:17 +08:00
|
|
|
%struct.S = type { [8192 x i8] }
|
2015-12-04 04:46:59 +08:00
|
|
|
|
2016-03-03 03:20:59 +08:00
|
|
|
define x86_thiscallcc void @call_inalloca(i1 %x) {
|
2015-12-04 04:46:59 +08:00
|
|
|
entry:
|
|
|
|
%argmem = alloca inalloca <{ %struct.S }>, align 4
|
|
|
|
%argidx1 = getelementptr inbounds <{ %struct.S }>, <{ %struct.S }>* %argmem, i32 0, i32 0, i32 0, i32 0
|
|
|
|
%argidx2 = getelementptr inbounds <{ %struct.S }>, <{ %struct.S }>* %argmem, i32 0, i32 0, i32 0, i32 1
|
|
|
|
store i8 42, i8* %argidx2, align 4
|
|
|
|
br i1 %x, label %bb1, label %bb2
|
|
|
|
|
|
|
|
bb1:
|
|
|
|
store i8 42, i8* %argidx1, align 4
|
|
|
|
br label %bb2
|
|
|
|
|
|
|
|
bb2:
|
|
|
|
call void @inalloca_params(<{ %struct.S }>* inalloca nonnull %argmem)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: _call_inalloca: # @call_inalloca
|
|
|
|
; CHECK: pushl %ebp
|
|
|
|
; CHECK: movl %esp, %ebp
|
2016-05-19 00:10:17 +08:00
|
|
|
; CHECK: movl $8192, %eax
|
2015-12-04 04:46:59 +08:00
|
|
|
; CHECK: calll __chkstk
|
|
|
|
; CHECK: calll _inalloca_params
|
|
|
|
; CHECK: movl %ebp, %esp
|
|
|
|
; CHECK: popl %ebp
|
|
|
|
; CHECK: retl
|
|
|
|
|
|
|
|
declare void @inalloca_params(<{ %struct.S }>* inalloca)
|
2016-02-17 08:17:33 +08:00
|
|
|
|
|
|
|
declare i32 @doSomething(i32, i32*)
|
|
|
|
|
|
|
|
; In this test case, we force usage of EAX before the prologue, and have to
|
|
|
|
; compensate before calling __chkstk. It would also be valid for us to avoid
|
|
|
|
; shrink wrapping in this case.
|
|
|
|
|
|
|
|
define x86_fastcallcc i32 @use_eax_before_prologue(i32 inreg %a, i32 inreg %b) {
|
|
|
|
%tmp = alloca i32, i32 1024, align 4
|
|
|
|
%tmp2 = icmp slt i32 %a, %b
|
|
|
|
br i1 %tmp2, label %true, label %false
|
|
|
|
|
|
|
|
true:
|
|
|
|
store i32 %a, i32* %tmp, align 4
|
|
|
|
%tmp4 = call i32 @doSomething(i32 0, i32* %tmp)
|
|
|
|
br label %false
|
|
|
|
|
|
|
|
false:
|
|
|
|
%tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]
|
|
|
|
ret i32 %tmp.0
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: @use_eax_before_prologue@8: # @use_eax_before_prologue
|
|
|
|
; CHECK: movl %ecx, %eax
|
2017-10-04 00:59:13 +08:00
|
|
|
; CHECK: cmpl %edx, %eax
|
2016-02-17 08:17:33 +08:00
|
|
|
; CHECK: jge LBB1_2
|
|
|
|
; CHECK: pushl %eax
|
2016-03-31 07:38:01 +08:00
|
|
|
; CHECK: movl $4092, %eax
|
2016-02-17 08:17:33 +08:00
|
|
|
; CHECK: calll __chkstk
|
2016-03-31 07:38:01 +08:00
|
|
|
; CHECK: movl 4092(%esp), %eax
|
2016-02-17 08:17:33 +08:00
|
|
|
; CHECK: calll _doSomething
|
|
|
|
; CHECK: LBB1_2:
|
|
|
|
; CHECK: retl
|