mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

When the target option GuaranteedTailCallOpt is specified, calls with the fastcc calling convention will be transformed into tail calls if they are in tail position. This diff adds a new calling convention, tailcc, currently supported only on X86, which behaves the same way as fastcc, except that the GuaranteedTailCallOpt flag does not need to enabled in order to enable tail call optimization. Patch by Dwight Guth <dwight.guth@runtimeverification.com>! Reviewed By: lebedev.ri, paquette, rnk Differential Revision: https://reviews.llvm.org/D67855 llvm-svn: 373976
50 lines
1.5 KiB
LLVM
50 lines
1.5 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc -tailcallopt < %s -mtriple=x86_64-unknown-unknown | FileCheck %s -check-prefix=X64
|
|
; RUN: llc -tailcallopt < %s -mtriple=i686-unknown-unknown | FileCheck %s -check-prefix=X32
|
|
|
|
; llc -tailcallopt should not enable tail calls from fastcc to tailcc or vice versa
|
|
|
|
declare tailcc i32 @tailcallee1(i32 %a1, i32 %a2, i32 %a3, i32 %a4)
|
|
|
|
define fastcc i32 @tailcaller1(i32 %in1, i32 %in2) nounwind {
|
|
; X64-LABEL: tailcaller1:
|
|
; X64: # %bb.0: # %entry
|
|
; X64-NEXT: pushq %rax
|
|
; X64-NEXT: movl %edi, %edx
|
|
; X64-NEXT: movl %esi, %ecx
|
|
; X64-NEXT: callq tailcallee1
|
|
; X64-NEXT: retq $8
|
|
;
|
|
; X32-LABEL: tailcaller1:
|
|
; X32: # %bb.0: # %entry
|
|
; X32-NEXT: pushl %edx
|
|
; X32-NEXT: pushl %ecx
|
|
; X32-NEXT: calll tailcallee1
|
|
; X32-NEXT: retl
|
|
entry:
|
|
%tmp11 = tail call tailcc i32 @tailcallee1(i32 %in1, i32 %in2, i32 %in1, i32 %in2)
|
|
ret i32 %tmp11
|
|
}
|
|
|
|
declare fastcc i32 @tailcallee2(i32 %a1, i32 %a2, i32 %a3, i32 %a4)
|
|
|
|
define tailcc i32 @tailcaller2(i32 %in1, i32 %in2) nounwind {
|
|
; X64-LABEL: tailcaller2:
|
|
; X64: # %bb.0: # %entry
|
|
; X64-NEXT: pushq %rax
|
|
; X64-NEXT: movl %edi, %edx
|
|
; X64-NEXT: movl %esi, %ecx
|
|
; X64-NEXT: callq tailcallee2
|
|
; X64-NEXT: retq $8
|
|
;
|
|
; X32-LABEL: tailcaller2:
|
|
; X32: # %bb.0: # %entry
|
|
; X32-NEXT: pushl %edx
|
|
; X32-NEXT: pushl %ecx
|
|
; X32-NEXT: calll tailcallee2
|
|
; X32-NEXT: retl
|
|
entry:
|
|
%tmp11 = tail call fastcc i32 @tailcallee2(i32 %in1, i32 %in2, i32 %in1, i32 %in2)
|
|
ret i32 %tmp11
|
|
}
|