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