[llvm] [WebAssembly] Implement lowering calls through funcref to call_ref when available (PR #162227)
Derek Schuff via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 14:50:12 PDT 2025
================
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc < %s -mattr=+reference-types,-gc | FileCheck --check-prefixes=CHECK,NOGC %s
+; RUN: llc < %s -mattr=+reference-types,+gc | FileCheck --check-prefixes=CHECK,GC %s
+
+; Test that calls through funcref lower to call_ref when GC is available
+
+target triple = "wasm32-unknown-unknown"
+
+%funcref = type ptr addrspace(20);
+
+define void @call_ref_void(%funcref %callee) {
+; CHECK-LABEL: call_ref_void:
+; CHECK: .functype call_ref_void (funcref) -> ()
+; CHECK-NEXT: # %bb.0:
+; NOGC-NEXT: i32.const 0
+; CHECK-NEXT: local.get 0
+; NOGC-NEXT: table.set __funcref_call_table
+; NOGC-NEXT: i32.const 0
+; NOGC-NEXT: call_indirect __funcref_call_table, () -> ()
+; NOGC-NEXT: i32.const 0
+; NOGC-NEXT: ref.null_func
+; NOGC-NEXT: table.set __funcref_call_table
+; GC-NEXT: ref.cast () -> ()
----------------
dschuff wrote:
@tlively I assume there is never an advantage to the NOGC version of this compared to the GC version? even if call_indirect is a bit faster than cast+call_ref, it still seems nicer than this dance with the tables.
https://github.com/llvm/llvm-project/pull/162227
More information about the llvm-commits
mailing list