@@ -232,15 +232,17 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
232232 const FunctionType *FuncTy = PtrTy->getPointeeType ()->getAs <FunctionType>();
233233 assert (FuncTy && " Sema should have ensured this is a function pointer" );
234234
235- // In the llvm IR, we won't have access anymore to the type of the function
236- // pointer so we need to insert this type information somehow. We gave the
237- // @llvm.wasm.ref.test.func varargs and here we add an extra 0 argument of
238- // the type corresponding to the type of each argument of the function
239- // signature. When we lower from the IR we'll use the types of these
240- // arguments to determine the signature we want to test for.
235+ // In the llvm IR, we won't have access any more to the type of the function
236+ // pointer so we need to insert this type information somehow. The
237+ // @llvm.wasm.ref.test.func takes varargs arguments whose values are unused
238+ // to indicate the type of the function to test for. See the test here:
239+ // llvm/test/CodeGen/WebAssembly/ref-test-func.ll
240+ //
241+ // The format is: first we include the return types (since this is a C
242+ // function pointer, there will be 0 or one of these) then a token type to
243+ // indicate the boundary between return types and param types, then the
244+ // param types.
241245
242- // Make a type index constant with 0. This gets replaced by the actual type
243- // in WebAssemblyMCInstLower.cpp.
244246 llvm::FunctionType *LLVMFuncTy =
245247 cast<llvm::FunctionType>(ConvertType (QualType (FuncTy, 0 )));
246248
@@ -259,7 +261,7 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
259261 } else if (T->isIntegerTy ()) {
260262 Args.push_back (ConstantInt::get (T, 0 ));
261263 } else {
262- // TODO: Handle reference types here . For now, we reject them in Sema.
264+ // TODO: Handle reference types. For now, we reject them in Sema.
263265 llvm_unreachable (" Unhandled type" );
264266 }
265267 };
0 commit comments