summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2019-08-28 16:19:01 +0000
committerJessica Paquette <jpaquette@apple.com>2019-08-28 16:19:01 +0000
commitaf0bd41e064f4608da29e741ad45fc4a6ef3abac (patch)
tree6e221e1e84e4c72bb8b7843d834dd39c41a171e1
parent1d8a886c596501f21366556b6e1e2d889a0b63dd (diff)
downloadbcm5719-llvm-af0bd41e064f4608da29e741ad45fc4a6ef3abac.tar.gz
bcm5719-llvm-af0bd41e064f4608da29e741ad45fc4a6ef3abac.zip
[AArch64][GlobalISel] Fall back when translating musttail calls
These are currently translated as normal functions calls in AArch64. Until we have proper tail call lowering, we shouldn't translate these. Differential Revision: https://reviews.llvm.org/D66842 llvm-svn: 370225
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h3
-rw-r--r--llvm/lib/CodeGen/GlobalISel/CallLowering.cpp1
-rw-r--r--llvm/lib/Target/AArch64/AArch64CallLowering.cpp5
-rw-r--r--llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll9
4 files changed, 18 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
index 3ff64b4c459..fa6c23a7e2c 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
@@ -80,6 +80,9 @@ public:
Register SwiftErrorVReg = 0;
MDNode *KnownCallees = nullptr;
+
+ /// True if the call must be tail call optimized.
+ bool IsMustTailCall = false;
};
/// Argument handling is mostly uniform between the four places that
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index efed4c281b5..5e08361fc05 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -62,6 +62,7 @@ bool CallLowering::lowerCall(MachineIRBuilder &MIRBuilder, ImmutableCallSite CS,
CS.getInstruction()->getMetadata(LLVMContext::MD_callees);
Info.CallConv = CS.getCallingConv();
Info.SwiftErrorVReg = SwiftErrorVReg;
+ Info.IsMustTailCall = CS.isMustTailCall();
return lowerCall(MIRBuilder, Info);
}
diff --git a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
index 5dd83b9b208..e389aaaeb71 100644
--- a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
@@ -409,6 +409,11 @@ bool AArch64CallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
MachineRegisterInfo &MRI = MF.getRegInfo();
auto &DL = F.getParent()->getDataLayout();
+ if (Info.IsMustTailCall) {
+ LLVM_DEBUG(dbgs() << "Cannot lower musttail calls yet.\n");
+ return false;
+ }
+
SmallVector<ArgInfo, 8> SplitArgs;
for (auto &OrigArg : Info.OrigArgs) {
splitToValueTypes(OrigArg, SplitArgs, DL, MRI, Info.CallConv);
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
new file mode 100644
index 00000000000..a93184e237e
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
@@ -0,0 +1,9 @@
+; RUN: not llc %s -mtriple aarch64-unknown-unknown -debug-only=aarch64-call-lowering -global-isel -o - 2>&1 | FileCheck %s
+
+; 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)
+ ret void
+}
OpenPOWER on IntegriCloud