[clang] [llvm] [WebAssembly] Change to 64-bit table indices on Wasm64 (PR #180649)

Sam Clegg via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 9 16:54:59 PST 2026


================
@@ -1,77 +1,101 @@
-; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s | FileCheck %s
+; RUN: sed 's/iX/i32/g' < %s | llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s --check-prefixes=CHECK,WASM32
+; RUN: sed 's/iX/i64/g' < %s | llc --mtriple=wasm64-unknown-unknown -asm-verbose=false -mattr=+reference-types | FileCheck %s --check-prefixes=CHECK,WASM64
 
 %funcref = type ptr addrspace(20) ;; addrspace 20 is nonintegral
 
 @funcref_table = local_unnamed_addr addrspace(1) global [0 x %funcref] undef
 
-declare void @llvm.wasm.table.set.funcref(ptr addrspace(1), i32, %funcref) nounwind
+declare void @llvm.wasm.table.set.funcref(ptr addrspace(1), iX, %funcref) nounwind
 
-define void @set_funcref_table(%funcref %g, i32 %i) {
+define void @set_funcref_table(%funcref %g, iX %i) {
 ; CHECK-LABEL: set_funcref_table:
-; CHECK-NEXT: .functype       set_funcref_table (funcref, i32) -> ()
-; CHECK-NEXT: local.get      1
-; CHECK-NEXT: local.get      0
-; CHECK-NEXT: table.set     funcref_table
-; CHECK-NEXT: end_function
+; WASM32-NEXT: .functype       set_funcref_table (funcref, i32) -> ()
+; WASM64-NEXT: .functype       set_funcref_table (funcref, i64) -> ()
+; CHECK-NEXT:  local.get      1
+; CHECK-NEXT:  local.get      0
+; CHECK-NEXT:  table.set     funcref_table
+; CHECK-NEXT:  end_function
 
 ;; this generates a table.set of @funcref_table
-  call void @llvm.wasm.table.set.funcref(ptr addrspace(1) @funcref_table, i32 %i, %funcref %g)
+  call void @llvm.wasm.table.set.funcref(ptr addrspace(1) @funcref_table, iX %i, %funcref %g)
   ret void
 }
 
 define void @set_funcref_table_const(%funcref %g) {
 ; CHECK-LABEL: set_funcref_table_const:
 ; CHECK-NEXT:  .functype      set_funcref_table_const (funcref) -> ()
-; CHECK-NEXT:  i32.const      0
+; WASM32-NEXT: i32.const      0
+; WASM64-NEXT: i64.const      0
----------------
sbc100 wrote:

In the lld tests we achieve this using `-DPTR=i32` argument to `FileCheck` and then using `; CHECK-NEXT: [[PTR]].const      0`

https://github.com/llvm/llvm-project/pull/180649


More information about the cfe-commits mailing list