<div dir="ltr"><div>In r370279, I've added "REQUIRES: asserts" to your test because the option "-debug-only" needs it.  Otherwise, some builds will fail the test with unknown command line option.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 28, 2019 at 9:17 AM Jessica Paquette via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: paquette<br>
Date: Wed Aug 28 09:19:01 2019<br>
New Revision: 370225<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=370225&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=370225&view=rev</a><br>
Log:<br>
[AArch64][GlobalISel] Fall back when translating musttail calls<br>
<br>
These are currently translated as normal functions calls in AArch64.<br>
<br>
Until we have proper tail call lowering, we shouldn't translate these.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D66842" rel="noreferrer" target="_blank">https://reviews.llvm.org/D66842</a><br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll<br>
Modified:<br>
    llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h<br>
    llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp<br>
    llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h?rev=370225&r1=370224&r2=370225&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h?rev=370225&r1=370224&r2=370225&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/CallLowering.h Wed Aug 28 09:19:01 2019<br>
@@ -80,6 +80,9 @@ public:<br>
     Register SwiftErrorVReg = 0;<br>
<br>
     MDNode *KnownCallees = nullptr;<br>
+<br>
+    /// True if the call must be tail call optimized.<br>
+    bool IsMustTailCall = false;<br>
   };<br>
<br>
   /// Argument handling is mostly uniform between the four places that<br>
<br>
Modified: llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp?rev=370225&r1=370224&r2=370225&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp?rev=370225&r1=370224&r2=370225&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/GlobalISel/CallLowering.cpp Wed Aug 28 09:19:01 2019<br>
@@ -62,6 +62,7 @@ bool CallLowering::lowerCall(MachineIRBu<br>
       CS.getInstruction()->getMetadata(LLVMContext::MD_callees);<br>
   Info.CallConv = CS.getCallingConv();<br>
   Info.SwiftErrorVReg = SwiftErrorVReg;<br>
+  Info.IsMustTailCall = CS.isMustTailCall();<br>
<br>
   return lowerCall(MIRBuilder, Info);<br>
 }<br>
<br>
Modified: llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp?rev=370225&r1=370224&r2=370225&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp?rev=370225&r1=370224&r2=370225&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp (original)<br>
+++ llvm/trunk/lib/Target/AArch64/AArch64CallLowering.cpp Wed Aug 28 09:19:01 2019<br>
@@ -409,6 +409,11 @@ bool AArch64CallLowering::lowerCall(Mach<br>
   MachineRegisterInfo &MRI = MF.getRegInfo();<br>
   auto &DL = F.getParent()->getDataLayout();<br>
<br>
+  if (Info.IsMustTailCall) {<br>
+    LLVM_DEBUG(dbgs() << "Cannot lower musttail calls yet.\n");<br>
+    return false;<br>
+  }<br>
+<br>
   SmallVector<ArgInfo, 8> SplitArgs;<br>
   for (auto &OrigArg : Info.OrigArgs) {<br>
     splitToValueTypes(OrigArg, SplitArgs, DL, MRI, Info.CallConv);<br>
<br>
Added: llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll?rev=370225&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll?rev=370225&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll (added)<br>
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll Wed Aug 28 09:19:01 2019<br>
@@ -0,0 +1,9 @@<br>
+; RUN: not llc %s -mtriple aarch64-unknown-unknown -debug-only=aarch64-call-lowering -global-isel -o - 2>&1 | FileCheck %s<br>
+<br>
+; CHECK: Cannot lower musttail calls yet.<br>
+; CHECK-NEXT: LLVM ERROR: unable to translate instruction: call (in function: foo)<br>
+declare void @must_callee(i8*)<br>
+define void @foo(i32*) {<br>
+  musttail call void @must_callee(i8* null)<br>
+  ret void<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>