Index: lib/Target/WebAssembly/WebAssemblyFastISel.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -700,6 +700,9 @@ if (Func && Func->isIntrinsic()) return false; + if (!Func && isa(Call->getCalledValue())) + return false; + FunctionType *FuncTy = Call->getFunctionType(); unsigned Opc; bool IsDirect = Func != nullptr; Index: test/CodeGen/WebAssembly/call.ll =================================================================== --- test/CodeGen/WebAssembly/call.ll +++ test/CodeGen/WebAssembly/call.ll @@ -150,6 +150,18 @@ ret void } +; CHECK-LABEL: call_bitcast_vararg: +; CHECK-NEXT: .result i32{{$}} +; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 2{{$}} +; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 3{{$}} +; CHECK-NEXT: i32.call $push[[L2:[0-9]+]]=, vararg_func@FUNCTION, $pop[[L0]], $pop[[L1]]{{$}} +; CHECK-NEXT: return $pop[[L2]]{{$}} +declare i32 @vararg_func(...) +define i32 @call_bitcast_vararg() { + %ret = call i32 bitcast (i32 (...)* @vararg_func to i32 (i32, i32)*)(i32 2, i32 3) + ret i32 %ret +} + ; TODO: test the following: ; - More argument combinations. ; - Tail call.