87 lines · plain
1; RUN: llc -mtriple=i686-- < %s | FileCheck %s2; RUN: llc -mtriple=i686-- -O0 < %s | FileCheck %s3; RUN: llc -mtriple=i686-- -disable-tail-calls < %s | FileCheck %s4 5declare void @t1_callee(ptr)6define void @t1(ptr %a) {7; CHECK-LABEL: t1:8; CHECK: jmp {{_?}}t1_callee9 musttail call void @t1_callee(ptr %a)10 ret void11}12 13declare ptr @t2_callee()14define ptr @t2() {15; CHECK-LABEL: t2:16; CHECK: jmp {{_?}}t2_callee17 %v = musttail call ptr @t2_callee()18 ret ptr %v19}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 %ebp26; CHECK: pushl %esi27; CHECK: andl $-32, %esp28; CHECK: movl %esp, %esi29; CHECK: popl %esi30; CHECK: popl %ebp31; CHECK-NEXT: jmp {{_?}}t3_callee32 %a = alloca i8, i32 %n33 call void @capture(ptr %a)34 musttail call void @t3_callee(i32 %n) nounwind35 ret void36}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 forwarded42; 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, 153 %n1 = sub i32 %n, 154 %r2 = musttail call i32 %fn(ptr %fn, i32 %n1, i32 %r1)55 ret i32 %r256}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 %ebp62; CHECK: movl %esp, %ebp63; CHECK: pushl %esi64; Align the stack.65; CHECK: andl $-32, %esp66; CHECK: movl %esp, %esi67; 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), %esp75; CHECK: popl %esi76; CHECK: popl %ebp77; CHECK: jmpl *%{{.*}}78 79entry:80 %a = alloca i8, i32 %n81 call void @capture(ptr %a)82 %r1 = add i32 %r, 183 %n1 = sub i32 %n, 184 %r2 = musttail call i32 %fn(ptr %fn, i32 %n1, i32 %r1)85 ret i32 %r286}87