brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · d3aa48c Raw
72 lines · plain
1; RUN: llc < %s -mtriple=x86_64-linux-gnu -tailcallopt -code-model=large -enable-misched=false | FileCheck %s2 3declare fastcc i32 @callee(i32 %arg)4define fastcc i32 @directcall(i32 %arg) {5entry:6; This is the large code model, so &callee may not fit into the jmp7; instruction.  Instead, stick it into a register.8;  CHECK: movabsq $callee, [[REGISTER:%r[a-z0-9]+]]9;  CHECK: jmpq    *[[REGISTER]]  # TAILCALL10  %res = tail call fastcc i32 @callee(i32 %arg)11  ret i32 %res12}13 14; Check that the register used for an indirect tail call doesn't15; clobber any of the arguments.16define fastcc i32 @indirect_manyargs(ptr %target) {17; Adjust the stack to enter the function.  (The amount of the18; adjustment may change in the future, in which case the location of19; the stack argument and the return adjustment will change too.)20;  CHECK: pushq21; Put the call target into R11, which won't be clobbered while restoring22; callee-saved registers and won't be used for passing arguments.23;  CHECK: movq %rdi, %rax24; Pass the stack argument.25;  CHECK: movl $7, 16(%rsp)26; Pass the register arguments, in the right registers.27;  CHECK: movl $1, %edi28;  CHECK: movl $2, %esi29;  CHECK: movl $3, %edx30;  CHECK: movl $4, %ecx31;  CHECK: movl $5, %r8d32;  CHECK: movl $6, %r9d33; Adjust the stack to "return".34;  CHECK: popq35; And tail-call to the target.36;  CHECK: jmpq *%rax  # TAILCALL37  %res = tail call fastcc i32 %target(i32 1, i32 2, i32 3, i32 4, i32 5,38                                      i32 6, i32 7)39  ret i32 %res40}41 42; Check that the register used for a direct tail call doesn't clobber43; any of the arguments.44declare fastcc i32 @manyargs_callee(i32,i32,i32,i32,i32,i32,i32)45define fastcc i32 @direct_manyargs() {46; Adjust the stack to enter the function.  (The amount of the47; adjustment may change in the future, in which case the location of48; the stack argument and the return adjustment will change too.)49;  CHECK: pushq50; Pass the stack argument.51;  CHECK: movl $7, 16(%rsp)52; This is the large code model, so &manyargs_callee may not fit into53; the jmp instruction.  Put it into a register which won't be clobbered54; while restoring callee-saved registers and won't be used for passing55; arguments.56;  CHECK: movabsq $manyargs_callee, %rax57; Pass the register arguments, in the right registers.58;  CHECK: movl $1, %edi59;  CHECK: movl $2, %esi60;  CHECK: movl $3, %edx61;  CHECK: movl $4, %ecx62;  CHECK: movl $5, %r8d63;  CHECK: movl $6, %r9d64; Adjust the stack to "return".65;  CHECK: popq66; And tail-call to the target.67;  CHECK: jmpq *%rax  # TAILCALL68  %res = tail call fastcc i32 @manyargs_callee(i32 1, i32 2, i32 3, i32 4,69                                               i32 5, i32 6, i32 7)70  ret i32 %res71}72