75 lines · plain
1; RUN: llc < %s -enable-shrink-wrap=true | FileCheck %s2 3; TODO: add preallocated versions of tests4; we don't yet support conditionally called preallocated calls after the setup5 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 preserving8; 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 418 %argidx2 = getelementptr inbounds <{ %struct.S }>, ptr %argmem, i32 0, i32 0, i32 0, i32 119 store i8 42, ptr %argidx2, align 420 br i1 %x, label %bb1, label %bb221 22bb1:23 store i8 42, ptr %argmem, align 424 br label %bb225 26bb2:27 call void @inalloca_params(ptr inalloca(<{ %struct.S }>) nonnull %argmem)28 ret void29}30 31; CHECK-LABEL: _call_inalloca: # @call_inalloca32; CHECK: pushl %ebp33; CHECK: movl %esp, %ebp34; CHECK: movl $8192, %eax35; CHECK: calll __chkstk36; CHECK: calll _inalloca_params37; CHECK: movl %ebp, %esp38; CHECK: popl %ebp39; CHECK: retl40 41declare void @inalloca_params(ptr inalloca(<{ %struct.S }>))42 43declare i32 @doSomething(i32, ptr)44 45; In this test case, we force usage of EAX before the prologue, and have to46; compensate before calling __chkstk. It would also be valid for us to avoid47; shrink wrapping in this case.48 49define x86_fastcallcc i32 @use_eax_before_prologue(i32 inreg %a, i32 inreg %b) {50 %tmp = alloca i32, i32 1024, align 451 %tmp2 = icmp slt i32 %a, %b52 br i1 %tmp2, label %true, label %false53 54true:55 store i32 %a, ptr %tmp, align 456 %tmp4 = call i32 @doSomething(i32 0, ptr %tmp)57 br label %false58 59false:60 %tmp.0 = phi i32 [ %tmp4, %true ], [ %a, %0 ]61 ret i32 %tmp.062}63 64; CHECK-LABEL: @use_eax_before_prologue@8: # @use_eax_before_prologue65; CHECK: movl %ecx, %eax66; CHECK: cmpl %edx, %ecx67; CHECK: jge LBB1_268; CHECK: pushl %eax69; CHECK: movl $4092, %eax70; CHECK: calll __chkstk71; CHECK: movl 4092(%esp), %eax72; CHECK: calll _doSomething73; CHECK: LBB1_2:74; CHECK: retl75