Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/CodeGen/X86/musttail.ll
Show All 40 Lines | |||||
declare void @t3_callee(i32) | declare void @t3_callee(i32) | ||||
; Test that we actually copy in and out stack arguments that aren't forwarded | ; Test that we actually copy in and out stack arguments that aren't forwarded | ||||
; without modification. | ; without modification. | ||||
define i32 @t4({}* %fn, i32 %n, i32 %r) { | define i32 @t4({}* %fn, i32 %n, i32 %r) { | ||||
; CHECK-LABEL: t4: | ; CHECK-LABEL: t4: | ||||
; CHECK: incl %[[r:.*]] | ; CHECK: incl %[[r:.*]] | ||||
; CHECK: decl %[[n:.*]] | ; CHECK: decl %[[n:.*]] | ||||
; CHECK: movl %[[r]], {{[0-9]+}}(%esp) | ; CHECK-DAG: movl %[[r]], {{[0-9]+}}(%esp) | ||||
; CHECK: movl %[[n]], {{[0-9]+}}(%esp) | ; CHECK-DAG: movl %[[n]], {{[0-9]+}}(%esp) | ||||
; CHECK: jmpl *%{{.*}} | ; CHECK: jmpl *%{{.*}} | ||||
entry: | entry: | ||||
%r1 = add i32 %r, 1 | %r1 = add i32 %r, 1 | ||||
%n1 = sub i32 %n, 1 | %n1 = sub i32 %n, 1 | ||||
%fn_cast = bitcast {}* %fn to i32 ({}*, i32, i32)* | %fn_cast = bitcast {}* %fn to i32 ({}*, i32, i32)* | ||||
%r2 = musttail call i32 %fn_cast({}* %fn, i32 %n1, i32 %r1) | %r2 = musttail call i32 %fn_cast({}* %fn, i32 %n1, i32 %r1) | ||||
ret i32 %r2 | ret i32 %r2 | ||||
} | } | ||||
; Combine the complex stack frame with the parameter modification. | ; Combine the complex stack frame with the parameter modification. | ||||
define i32 @t5({}* %fn, i32 %n, i32 %r) alignstack(32) { | define i32 @t5({}* %fn, i32 %n, i32 %r) alignstack(32) { | ||||
; CHECK-LABEL: t5: | ; CHECK-LABEL: t5: | ||||
; CHECK: pushl %ebp | ; CHECK: pushl %ebp | ||||
; CHECK: movl %esp, %ebp | ; CHECK: movl %esp, %ebp | ||||
; CHECK: pushl %esi | ; CHECK: pushl %esi | ||||
; Align the stack. | ; Align the stack. | ||||
; CHECK: andl $-32, %esp | ; CHECK: andl $-32, %esp | ||||
; CHECK: movl %esp, %esi | ; CHECK: movl %esp, %esi | ||||
; Modify the args. | ; Modify the args. | ||||
; CHECK: incl %[[r:.*]] | ; CHECK: incl %[[r:.*]] | ||||
; CHECK: decl %[[n:.*]] | ; CHECK: decl %[[n:.*]] | ||||
; Store them through ebp, since that's the only stable arg pointer. | ; Store them through ebp, since that's the only stable arg pointer. | ||||
; CHECK: movl %[[r]], {{[0-9]+}}(%ebp) | ; CHECK-DAG: movl %[[r]], {{[0-9]+}}(%ebp) | ||||
; CHECK: movl %[[n]], {{[0-9]+}}(%ebp) | ; CHECK-DAG: movl %[[n]], {{[0-9]+}}(%ebp) | ||||
; Epilogue. | ; Epilogue. | ||||
; CHECK: leal {{[-0-9]+}}(%ebp), %esp | ; CHECK: leal {{[-0-9]+}}(%ebp), %esp | ||||
; CHECK: popl %esi | ; CHECK: popl %esi | ||||
; CHECK: popl %ebp | ; CHECK: popl %ebp | ||||
; CHECK: jmpl *%{{.*}} | ; CHECK: jmpl *%{{.*}} | ||||
entry: | entry: | ||||
%a = alloca i8, i32 %n | %a = alloca i8, i32 %n | ||||
call void @capture(i8* %a) | call void @capture(i8* %a) | ||||
%r1 = add i32 %r, 1 | %r1 = add i32 %r, 1 | ||||
%n1 = sub i32 %n, 1 | %n1 = sub i32 %n, 1 | ||||
%fn_cast = bitcast {}* %fn to i32 ({}*, i32, i32)* | %fn_cast = bitcast {}* %fn to i32 ({}*, i32, i32)* | ||||
%r2 = musttail call i32 %fn_cast({}* %fn, i32 %n1, i32 %r1) | %r2 = musttail call i32 %fn_cast({}* %fn, i32 %n1, i32 %r1) | ||||
ret i32 %r2 | ret i32 %r2 | ||||
} | } |