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
|
[MachineCopyPropagation] Extend pass to do COPY source forwarding
Summary:
This change extends MachineCopyPropagation to do COPY source forwarding
and adds an additional run of the pass to the default pass pipeline just
after register allocation.
This version of this patch uses the newly added
MachineOperand::isRenamable bit to avoid forwarding registers is such a
way as to violate constraints that aren't captured in the
Machine IR (e.g. ABI or ISA constraints).
This change is a continuation of the work started in D30751.
Reviewers: qcolombet, javed.absar, MatzeB, jonpa, tstellar
Subscribers: tpr, mgorny, mcrosier, nhaehnle, nemanjai, jyknight, hfinkel, arsenm, inouehrs, eraman, sdardis, guyblank, fedor.sergeev, aheejin, dschuff, jfb, myatsina, llvm-commits
Differential Revision: https://reviews.llvm.org/D41835
llvm-svn: 323991
2018-02-02 02:54:01 +08:00
|
|
|
; CHECK: cmpl %edx, %ecx
|
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
|