]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] FastISel : Bail to SelectionDAG for constexpr calls
authorJacob Gravelle <jgravelle@google.com>
Thu, 24 Aug 2017 19:53:44 +0000 (19:53 +0000)
committerJacob Gravelle <jgravelle@google.com>
Thu, 24 Aug 2017 19:53:44 +0000 (19:53 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311693 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/WebAssemblyFastISel.cpp
test/CodeGen/WebAssembly/call.ll

index c980f4b87f9160dce050080dffd3590b757ce7a0..f516a6b260d13927bd0a8809337bc8faabc690fc 100644 (file)
@@ -700,9 +700,12 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) {
   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) {
index 1cf42242a6cc2fcbb9ebb782b107624b62950517..dfa0cf5efe0bdf1891a81656479ab62f59187804 100644 (file)
@@ -150,6 +150,27 @@ define void @coldcc_tail_call_void_nullary() {
   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@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}}
+; CHECK-NEXT: call other_void_nullary@FUNCTION{{$}}
+; CHECK-NEXT: call void_nullary@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.