summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/AArch64/GlobalISel
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2019-09-18 22:42:25 +0000
committerJessica Paquette <jpaquette@apple.com>2019-09-18 22:42:25 +0000
commitce65ebc39e5bac42308038aab90507611d319d26 (patch)
treef006c97f7dfa4b235407f897c5eb4cfb41b35f25 /llvm/test/CodeGen/AArch64/GlobalISel
parent0779dffbd4a927d7bf9523482481248c51796907 (diff)
downloadbcm5719-llvm-ce65ebc39e5bac42308038aab90507611d319d26.tar.gz
bcm5719-llvm-ce65ebc39e5bac42308038aab90507611d319d26.zip
[AArch64][GlobalISel] Support lowering musttail calls
Since we now lower most tail calls, it makes sense to support musttail. Instead of always falling back to SelectionDAG, only fall back when a musttail call was not able to be emitted as a tail call. Once we can handle most incoming and outgoing arguments, we can change this to a `report_fatal_error` like in ISelLowering. Remove the assert that we don't have varargs and a musttail, and replace it with a return false. Implementing this requires that we implement `saveVarArgRegisters` from AArch64ISelLowering, which is an entirely different patch. Add GlobalISel lines to vararg-tallcall.ll to make sure that we produce correct code. Right now we only fall back, but eventually this will be relevant. Differential Revision: https://reviews.llvm.org/D67681 llvm-svn: 372273
Diffstat (limited to 'llvm/test/CodeGen/AArch64/GlobalISel')
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll15
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll15
2 files changed, 24 insertions, 6 deletions
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
index 7d6ba8489b7..72af098a894 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
@@ -1,10 +1,13 @@
-; RUN: not llc %s -mtriple aarch64-unknown-unknown -debug-only=aarch64-call-lowering -global-isel -o - 2>&1 | FileCheck %s
+; RUN: not llc %s -mtriple aarch64-apple-darwin -debug-only=aarch64-call-lowering -global-isel -global-isel-abort=2 -o - 2>&1 | FileCheck %s
; REQUIRES: asserts
-; CHECK: Cannot lower musttail calls yet.
-; CHECK-NEXT: LLVM ERROR: unable to translate instruction: call (in function: foo)
-declare void @must_callee(i8*)
-define void @foo(i32*) {
- musttail call void @must_callee(i8* null)
+; Verify that we fall back to SelectionDAG, and error out when we can't tail call musttail functions
+; CHECK: ... Cannot tail call externally-defined function with weak linkage for this OS.
+; CHECK-NEXT: Failed to lower musttail call as tail call
+; CHECK-NEXT: warning: Instruction selection used fallback path for caller_weak
+; CHECK-NEXT: LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
+declare extern_weak void @callee_weak()
+define void @caller_weak() {
+ musttail call void @callee_weak()
ret void
}
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
index 5be29e04512..78ab27e1039 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
@@ -224,3 +224,18 @@ define hidden swiftcc i64 @swiftself_indirect_tail(i64* swiftself %arg) {
%tmp2 = tail call swiftcc i64 %tmp1(i64* swiftself %arg)
ret i64 %tmp2
}
+
+; Verify that we can tail call musttail callees.
+declare void @must_callee(i8*)
+define void @foo(i32*) {
+ ; COMMON-LABEL: name: foo
+ ; COMMON: bb.1 (%ir-block.1):
+ ; COMMON: liveins: $x0
+ ; COMMON: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
+ ; COMMON: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
+ ; COMMON: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[C]](s64)
+ ; COMMON: $x0 = COPY [[INTTOPTR]](p0)
+ ; COMMON: TCRETURNdi @must_callee, 0, csr_aarch64_aapcs, implicit $sp, implicit $x0
+ musttail call void @must_callee(i8* null)
+ ret void
+}
OpenPOWER on IntegriCloud