1; RUN: llc -mtriple=i686-- < %s | FileCheck %s 2; RUN: llc -mtriple=i686-- -O0 < %s | FileCheck %s 3; RUN: llc -mtriple=i686-- -disable-tail-calls < %s | FileCheck %s 4 5declare void @t1_callee(ptr) 6define void @t1(ptr %a) { 7; CHECK-LABEL: t1: 8; CHECK: jmp {{_?}}t1_callee 9 musttail call void @t1_callee(ptr %a) 10 ret void 11} 12 13declare ptr @t2_callee() 14define ptr @t2() { 15; CHECK-LABEL: t2: 16; CHECK: jmp {{_?}}t2_callee 17 %v = musttail call ptr @t2_callee() 18 ret ptr %v 19} 20 21; Complex frame layout: stack realignment with dynamic alloca. 22define void @t3(i32 %n) alignstack(32) nounwind { 23entry: 24; CHECK: t3: 25; CHECK: pushl %ebp 26; CHECK: pushl %esi 27; CHECK: andl $-32, %esp 28; CHECK: movl %esp, %esi 29; CHECK: popl %esi 30; CHECK: popl %ebp 31; CHECK-NEXT: jmp {{_?}}t3_callee 32 %a = alloca i8, i32 %n 33 call void @capture(ptr %a) 34 musttail call void @t3_callee(i32 %n) nounwind 35 ret void 36} 37 38declare void @capture(ptr) 39declare void @t3_callee(i32) 40 41; Test that we actually copy in and out stack arguments that aren't forwarded 42; without modification. 43define i32 @t4(ptr %fn, i32 %n, i32 %r) { 44; CHECK-LABEL: t4: 45; CHECK: incl %[[r:.*]] 46; CHECK: decl %[[n:.*]] 47; CHECK-DAG: movl %[[r]], {{[0-9]+}}(%esp) 48; CHECK-DAG: movl %[[n]], {{[0-9]+}}(%esp) 49; CHECK: jmpl *%{{.*}} 50 51entry: 52 %r1 = add i32 %r, 1 53 %n1 = sub i32 %n, 1 54 %r2 = musttail call i32 %fn(ptr %fn, i32 %n1, i32 %r1) 55 ret i32 %r2 56} 57 58; Combine the complex stack frame with the parameter modification. 59define i32 @t5(ptr %fn, i32 %n, i32 %r) alignstack(32) { 60; CHECK-LABEL: t5: 61; CHECK: pushl %ebp 62; CHECK: movl %esp, %ebp 63; CHECK: pushl %esi 64; Align the stack. 65; CHECK: andl $-32, %esp 66; CHECK: movl %esp, %esi 67; Modify the args. 68; CHECK: incl %[[r:.*]] 69; CHECK: decl %[[n:.*]] 70; Store them through ebp, since that's the only stable arg pointer. 71; CHECK-DAG: movl %[[r]], {{[0-9]+}}(%ebp) 72; CHECK-DAG: movl %[[n]], {{[0-9]+}}(%ebp) 73; Epilogue. 74; CHECK: leal {{[-0-9]+}}(%ebp), %esp 75; CHECK: popl %esi 76; CHECK: popl %ebp 77; CHECK: jmpl *%{{.*}} 78 79entry: 80 %a = alloca i8, i32 %n 81 call void @capture(ptr %a) 82 %r1 = add i32 %r, 1 83 %n1 = sub i32 %n, 1 84 %r2 = musttail call i32 %fn(ptr %fn, i32 %n1, i32 %r1) 85 ret i32 %r2 86} 87