[llvm] r370225 - [AArch64][GlobalISel] Fall back when translating musttail calls

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 09:19:01 PDT 2019


Author: paquette
Date: Wed Aug 28 09:19:01 2019
New Revision: 370225

URL: http://llvm.org/viewvc/llvm-project?rev=370225&view=rev
Log:
[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

Added:
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h
    llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp
    llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h?rev=370225&r1=370224&r2=370225&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h Wed Aug 28 09:19:01 2019
@@ -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

Modified: llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp?rev=370225&r1=370224&r2=370225&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp Wed Aug 28 09:19:01 2019
@@ -62,6 +62,7 @@ bool CallLowering::lowerCall(MachineIRBu
       CS.getInstruction()->getMetadata(LLVMContext::MD_callees);
   Info.CallConv = CS.getCallingConv();
   Info.SwiftErrorVReg = SwiftErrorVReg;
+  Info.IsMustTailCall = CS.isMustTailCall();
 
   return lowerCall(MIRBuilder, Info);
 }

Modified: llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp?rev=370225&r1=370224&r2=370225&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp Wed Aug 28 09:19:01 2019
@@ -409,6 +409,11 @@ bool AArch64CallLowering::lowerCall(Mach
   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);

Added: llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll?rev=370225&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll Wed Aug 28 09:19:01 2019
@@ -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
+}




More information about the llvm-commits mailing list