[llvm] [WebAssembly] Print type signature and table for call_indirect (PR #179120)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 20:53:40 PST 2026
aheejin wrote:
> Adding the reference-types attribute does not cause an error.
>
> ```
>
> $ bin/llvm-mc -triple=wasm32 -mattr=+tail-call,+reference-types -show-encoding tail.s
> .file "tail.ll"
> .tabletype __indirect_function_table, funcref
> .functype indirect_musttail (i32, i32) -> (i32)
> .section .text.indirect_musttail,"",@
> .globl indirect_musttail
> indirect_musttail:
> .functype indirect_musttail (i32, i32) -> (i32)
> local.get 0 # encoding: [0x20,0x00]
> local.get 1 # encoding: [0x20,0x01]
> local.get 0 # encoding: [0x20,0x00]
> return_call_indirect __indirect_function_table, (i32, i32) -> (i32) # encoding: [0x13,0x80'A',0x80'A',0x80'A',0x80'A',A,0x80'B',0x80'B',0x80'B',0x80'B',B]
> # fixup A - offset: 1, value: .Ltypeindex0 at TYPEINDEX, kind: fixup_uleb128_i32
> # fixup B - offset: 6, value: __indirect_function_table, kind: fixup_uleb128_i32
> end_function # encoding: [0x0b]
> .section .custom_section.target_features,"",@
>
> ```
The reason `llc` prints `__indirect_function_table` without `-mattr=+reference-types` but `llvm-mc` cannot parse it without it was, `llc` was using `generic` CPU by default, but `llvm-mc` was not.
https://github.com/llvm/llvm-project/blob/75f738b0b2a15281c6f285380ea947e973a6e02f/llvm/lib/Target/WebAssembly/WebAssembly.td#L129-L139
For consistency, I updated `llvm-mc` to use `generic` CPU as well in #181460. This isn't necessarily related to this PR though.
https://github.com/llvm/llvm-project/pull/179120
More information about the llvm-commits
mailing list