From d0ddfb08967515b6e4630a90f3a78bd90118f9c9 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Wed, 13 Aug 2014 23:23:58 +0000 Subject: [PATCH] [AArch64, fast-isel] Fall back to SelectionDAG to select tail calls. Certain functions such as objc_autoreleaseReturnValue have to be called as tail-calls even at -O0. Since normal fast-isel doesn't emit calls as tail calls, we have to fall back to SelectionDAG to select calls that are marked as tail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215600 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64FastISel.cpp | 5 +++++ test/CodeGen/AArch64/arm64-abi_align.ll | 4 +++- test/CodeGen/AArch64/tailcall-fastisel.ll | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/AArch64/tailcall-fastisel.ll diff --git a/lib/Target/AArch64/AArch64FastISel.cpp b/lib/Target/AArch64/AArch64FastISel.cpp index a59ee85423b..5459c1ba4f7 100644 --- a/lib/Target/AArch64/AArch64FastISel.cpp +++ b/lib/Target/AArch64/AArch64FastISel.cpp @@ -1687,10 +1687,15 @@ bool AArch64FastISel::FinishCall(CallLoweringInfo &CLI, MVT RetVT, bool AArch64FastISel::FastLowerCall(CallLoweringInfo &CLI) { CallingConv::ID CC = CLI.CallConv; + bool IsTailCall = CLI.IsTailCall; bool IsVarArg = CLI.IsVarArg; const Value *Callee = CLI.Callee; const char *SymName = CLI.SymName; + // Allow SelectionDAG isel to handle tail calls. + if (IsTailCall) + return false; + CodeModel::Model CM = TM.getCodeModel(); // Only support the small and large code model. if (CM != CodeModel::Small && CM != CodeModel::Large) diff --git a/test/CodeGen/AArch64/arm64-abi_align.ll b/test/CodeGen/AArch64/arm64-abi_align.ll index 23e8f42eb88..deb740e50c3 100644 --- a/test/CodeGen/AArch64/arm64-abi_align.ll +++ b/test/CodeGen/AArch64/arm64-abi_align.ll @@ -511,7 +511,9 @@ entry: ; CHECK: str {{w[0-9]+}}, [sp] ; FAST-LABEL: i64_split ; FAST: ldr x7, [{{x[0-9]+}}] -; FAST: str {{w[0-9]+}}, [sp] +; FAST: mov x[[R0:[0-9]+]], sp +; FAST: orr w[[R1:[0-9]+]], wzr, #0x8 +; FAST: str w[[R1]], {{\[}}x[[R0]]{{\]}} %0 = load i64* bitcast (%struct.s41* @g41 to i64*), align 16 %call = tail call i32 @callee_i64(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i64 %0, i32 8) #5 diff --git a/test/CodeGen/AArch64/tailcall-fastisel.ll b/test/CodeGen/AArch64/tailcall-fastisel.ll new file mode 100644 index 00000000000..3ba63918316 --- /dev/null +++ b/test/CodeGen/AArch64/tailcall-fastisel.ll @@ -0,0 +1,11 @@ +; RUN: llc < %s -mtriple=arm64-apple-darwin -O0 | FileCheck %s + +; CHECK: b _foo0 + +define i32 @foo1() { +entry: + %call = tail call i32 @foo0() + ret i32 %call +} + +declare i32 @foo0() -- 2.11.0