[llvm] r249184 - [WebAssembly] Support calls marked as "tail", fastcc, and coldcc.

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 13:54:24 PDT 2015


Author: djg
Date: Fri Oct  2 15:54:23 2015
New Revision: 249184

URL: http://llvm.org/viewvc/llvm-project?rev=249184&view=rev
Log:
[WebAssembly] Support calls marked as "tail", fastcc, and coldcc.

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
    llvm/trunk/test/CodeGen/WebAssembly/call.ll

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp?rev=249184&r1=249183&r2=249184&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp Fri Oct  2 15:54:23 2015
@@ -229,13 +229,23 @@ WebAssemblyTargetLowering::LowerCall(Cal
   MachineFunction &MF = DAG.getMachineFunction();
 
   CallingConv::ID CallConv = CLI.CallConv;
-  if (CallConv != CallingConv::C)
-    fail(DL, DAG, "WebAssembly doesn't support non-C calling conventions");
-  if (CLI.IsTailCall || MF.getTarget().Options.GuaranteedTailCallOpt)
-    fail(DL, DAG, "WebAssembly doesn't support tail call yet");
+  if (CallConv != CallingConv::C &&
+      CallConv != CallingConv::Fast &&
+      CallConv != CallingConv::Cold)
+    fail(DL, DAG,
+         "WebAssembly doesn't support language-specific or target-specific "
+         "calling conventions yet");
   if (CLI.IsPatchPoint)
     fail(DL, DAG, "WebAssembly doesn't support patch point yet");
 
+  // WebAssembly doesn't currently support explicit tail calls. If they are
+  // required, fail. Otherwise, just disable them.
+  if ((CallConv == CallingConv::Fast && CLI.IsTailCall &&
+       MF.getTarget().Options.GuaranteedTailCallOpt) ||
+      (CLI.CS && CLI.CS->isMustTailCall()))
+    fail(DL, DAG, "WebAssembly doesn't support tail call yet");
+  CLI.IsTailCall = false;
+
   SmallVectorImpl<ISD::OutputArg> &Outs = CLI.Outs;
   SmallVectorImpl<SDValue> &OutVals = CLI.OutVals;
 

Modified: llvm/trunk/test/CodeGen/WebAssembly/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call.ll?rev=249184&r1=249183&r2=249184&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call.ll Fri Oct  2 15:54:23 2015
@@ -98,8 +98,31 @@ define i32 @call_indirect_i32(i32 ()* %c
   ret i32 %t
 }
 
+; CHECK-LABEL: (func $tail_call_void_nullary
+; CHECK-NEXT: (call $void_nullary)
+; CHECK-NEXT: (return)
+define void @tail_call_void_nullary() {
+  tail call void @void_nullary()
+  ret void
+}
+
+; CHECK-LABEL: (func $fastcc_tail_call_void_nullary
+; CHECK-NEXT: (call $void_nullary)
+; CHECK-NEXT: (return)
+define void @fastcc_tail_call_void_nullary() {
+  tail call fastcc void @void_nullary()
+  ret void
+}
+
+; CHECK-LABEL: (func $coldcc_tail_call_void_nullary
+; CHECK-NEXT: (call $void_nullary)
+; CHECK-NEXT: (return)
+define void @coldcc_tail_call_void_nullary() {
+  tail call coldcc void @void_nullary()
+  ret void
+}
+
 ; FIXME test the following:
-;  - Functions without return.
 ;  - More argument combinations.
 ;  - Tail call.
 ;  - Interesting returns (struct, multiple).




More information about the llvm-commits mailing list