[clang] [WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (PR #150201)
Thomas Lively via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 12:15:43 PDT 2025
================
@@ -199,6 +199,12 @@ TARGET_BUILTIN(__builtin_wasm_ref_is_null_extern, "ii", "nct", "reference-types"
// return type.
TARGET_BUILTIN(__builtin_wasm_ref_null_func, "i", "nct", "reference-types")
+// Check if the runtime type of a function pointer matches its static type. Used
+// to avoid "function signature mismatch" traps. Takes a function pointer, uses
+// table.get to look up the pointer in __indirect_function_table and then
+// ref.test to test the type.
+TARGET_BUILTIN(__builtin_wasm_test_function_pointer_signature, "i.", "nct", "reference-types")
----------------
tlively wrote:
`ref.test` is only added with the GC proposal, so if we emit it with only reference-types enabled, the resulting binary will not validate in wasm-opt. We need to introduce a new `gc` feature that puts `"gc"` in the target features section, then make this builtin depend on that new feature.
https://github.com/llvm/llvm-project/pull/150201
More information about the cfe-commits
mailing list