[llvm] r311693 - [WebAssembly] FastISel : Bail to SelectionDAG for constexpr calls

Jacob Gravelle via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 12:53:44 PDT 2017


Author: jgravelle
Date: Thu Aug 24 12:53:44 2017
New Revision: 311693

URL: http://llvm.org/viewvc/llvm-project?rev=311693&view=rev
Log:
[WebAssembly] FastISel : Bail to SelectionDAG for constexpr calls

Summary: Currently FastISel lowers constexpr calls as indirect calls.
We'd like those to direct calls, and falling back to SelectionDAGISel
handles that.

Reviewers: dschuff, sunfish

Subscribers: jfb, sbc100, llvm-commits, aheejin

Differential Revision: https://reviews.llvm.org/D37073

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

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp?rev=311693&r1=311692&r2=311693&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp Thu Aug 24 12:53:44 2017
@@ -700,9 +700,12 @@ bool WebAssemblyFastISel::selectCall(con
   if (Func && Func->isIntrinsic())
     return false;
 
+  bool IsDirect = Func != nullptr;
+  if (!IsDirect && isa<ConstantExpr>(Call->getCalledValue()))
+    return false;
+
   FunctionType *FuncTy = Call->getFunctionType();
   unsigned Opc;
-  bool IsDirect = Func != nullptr;
   bool IsVoid = FuncTy->getReturnType()->isVoidTy();
   unsigned ResultReg;
   if (IsVoid) {

Modified: llvm/trunk/test/CodeGen/WebAssembly/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call.ll?rev=311693&r1=311692&r2=311693&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call.ll Thu Aug 24 12:53:44 2017
@@ -150,6 +150,27 @@ define void @coldcc_tail_call_void_nulla
   ret void
 }
 
+; CHECK-LABEL: call_constexpr:
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 2{{$}}
+; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 3{{$}}
+; CHECK-NEXT: call vararg_func at FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
+; CHECK-NEXT: call other_void_nullary at FUNCTION{{$}}
+; CHECK-NEXT: call void_nullary at FUNCTION{{$}}
+; CHECK-NEXT: return{{$}}
+declare void @vararg_func(...)
+declare void @other_void_nullary()
+define void @call_constexpr() {
+bb0:
+  call void bitcast (void (...)* @vararg_func to void (i32, i32)*)(i32 2, i32 3)
+  br label %bb1
+bb1:
+  call void select (i1 0, void ()* @void_nullary, void ()* @other_void_nullary)()
+  br label %bb2
+bb2:
+  call void inttoptr (i32 ptrtoint (void ()* @void_nullary to i32) to void ()*)()
+  ret void
+}
+
 ; TODO: test the following:
 ;  - More argument combinations.
 ;  - Tail call.




More information about the llvm-commits mailing list