mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
d84c7b0582
This adds support for lowering sibling calls with outgoing arguments. e.g ``` define void @foo(i32 %a) ``` Support is ported from AArch64ISelLowering's `isEligibleForTailCallOptimization`. The only thing that is missing is a full port of `TargetLowering::parametersInCSRMatch`. So, if we're using swiftself, we'll never tail call. - Rename `analyzeCallResult` to `analyzeArgInfo`, since the function is now used for both outgoing and incoming arguments - Teach `OutgoingArgHandler` about tail calls. Tail calls use frame indices for stack arguments. - Teach `lowerFormalArguments` to set the bytes in the caller's stack argument area. This is used later to check if the tail call's parameters will fit on the caller's stack. - Add `areCalleeOutgoingArgsTailCallable` to perform the eligibility check on the callee's outgoing arguments. For testing: - Update call-translator-tail-call to verify that we can now tail call with outgoing arguments, use G_FRAME_INDEX for stack arguments, and respect the size of the caller's stack - Remove GISel-specific check lines from speculation-hardening.ll, since GISel now tail calls like the other selectors - Add a GISel test line to tailcall-string-rvo.ll since we can tail call in that test now - Add a GISel test line to tailcall_misched_graph.ll since we tail call there now. Add specific check lines for GISel, since the debug output from the machine-scheduler differs with GlobalISel. The dependency still holds, but the output comes out in a different order. Differential Revision: https://reviews.llvm.org/D67471 llvm-svn: 371780
49 lines
2.3 KiB
LLVM
49 lines
2.3 KiB
LLVM
; RUN: llc -relocation-model=static -verify-machineinstrs -O2 < %s | FileCheck %s
|
|
; RUN: llc -relocation-model=static -verify-machineinstrs -global-isel -O2 < %s | FileCheck %s
|
|
|
|
; The call to function TestBar should be a tail call, when in C++ the string
|
|
; `ret` is RVO returned.
|
|
; string TestFoo() {
|
|
; string ret = undef;
|
|
; TestBar(&ret); // tail call optimized
|
|
; return ret;
|
|
; }
|
|
|
|
target triple = "aarch64-linux-gnu"
|
|
|
|
%class.basic_string.11.42.73 = type { %"class.__gnu_cxx::__versa_string.10.41.72" }
|
|
%"class.__gnu_cxx::__versa_string.10.41.72" = type { %"class.__gnu_cxx::__sso_string_base.9.40.71" }
|
|
%"class.__gnu_cxx::__sso_string_base.9.40.71" = type { %"struct.__gnu_cxx::__vstring_utility<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider.7.38.69", i64, %union.anon.8.39.70 }
|
|
%"struct.__gnu_cxx::__vstring_utility<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider.7.38.69" = type { i8* }
|
|
%union.anon.8.39.70 = type { i64, [8 x i8] }
|
|
|
|
declare void @TestBaz(%class.basic_string.11.42.73* noalias sret %arg)
|
|
|
|
define void @TestBar(%class.basic_string.11.42.73* noalias sret %arg) {
|
|
bb:
|
|
call void @TestBaz(%class.basic_string.11.42.73* noalias sret %arg)
|
|
ret void
|
|
}
|
|
|
|
define void @TestFoo(%class.basic_string.11.42.73* noalias sret %arg) {
|
|
; CHECK-LABEL: TestFoo:
|
|
; CHECK: b TestBar
|
|
bb:
|
|
%tmp = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 2
|
|
%tmp1 = bitcast %class.basic_string.11.42.73* %arg to %union.anon.8.39.70**
|
|
store %union.anon.8.39.70* %tmp, %union.anon.8.39.70** %tmp1, align 8
|
|
%tmp2 = bitcast %union.anon.8.39.70* %tmp to i8*
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* nonnull undef, i64 13, i1 false)
|
|
%tmp3 = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 1
|
|
store i64 13, i64* %tmp3, align 8
|
|
%tmp4 = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 2, i32 1, i64 5
|
|
store i8 0, i8* %tmp4, align 1
|
|
tail call void @TestBar(%class.basic_string.11.42.73* noalias sret %arg)
|
|
ret void
|
|
}
|
|
|
|
; Function Attrs: argmemonly nounwind
|
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) #0
|
|
|
|
attributes #0 = { argmemonly nounwind }
|