1*f4a2713aSLionel Sambuc; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -tailcallopt | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc; FIXME: Win64 does not support byval. 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc; Expect the entry point. 6*f4a2713aSLionel Sambuc; CHECK-LABEL: tailcaller: 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc; Expect 2 rep;movs because of tail call byval lowering. 9*f4a2713aSLionel Sambuc; CHECK: rep; 10*f4a2713aSLionel Sambuc; CHECK: rep; 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc; A sequence of copyto/copyfrom virtual registers is used to deal with byval 13*f4a2713aSLionel Sambuc; lowering appearing after moving arguments to registers. The following two 14*f4a2713aSLionel Sambuc; checks verify that the register allocator changes those sequences to direct 15*f4a2713aSLionel Sambuc; moves to argument register where it can (for registers that are not used in 16*f4a2713aSLionel Sambuc; byval lowering - not rsi, not rdi, not rcx). 17*f4a2713aSLionel Sambuc; Expect argument 4 to be moved directly to register edx. 18*f4a2713aSLionel Sambuc; CHECK: movl $7, %edx 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc; Expect argument 6 to be moved directly to register r8. 21*f4a2713aSLionel Sambuc; CHECK: movl $17, %r8d 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc; Expect not call but jmp to @tailcallee. 24*f4a2713aSLionel Sambuc; CHECK: jmp tailcallee 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc; Expect the trailer. 27*f4a2713aSLionel Sambuc; CHECK: .size tailcaller 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc%struct.s = type { i64, i64, i64, i64, i64, i64, i64, i64, 30*f4a2713aSLionel Sambuc i64, i64, i64, i64, i64, i64, i64, i64, 31*f4a2713aSLionel Sambuc i64, i64, i64, i64, i64, i64, i64, i64 } 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambucdeclare fastcc i64 @tailcallee(%struct.s* byval %a, i64 %val, i64 %val2, i64 %val3, i64 %val4, i64 %val5) 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambucdefine fastcc i64 @tailcaller(i64 %b, %struct.s* byval %a) { 37*f4a2713aSLionel Sambucentry: 38*f4a2713aSLionel Sambuc %tmp2 = getelementptr %struct.s* %a, i32 0, i32 1 39*f4a2713aSLionel Sambuc %tmp3 = load i64* %tmp2, align 8 40*f4a2713aSLionel Sambuc %tmp4 = tail call fastcc i64 @tailcallee(%struct.s* byval %a , i64 %tmp3, i64 %b, i64 7, i64 13, i64 17) 41*f4a2713aSLionel Sambuc ret i64 %tmp4 42*f4a2713aSLionel Sambuc} 43