[llvm] [WebAssembly] Print type signature and table for call_indirect (PR #179120)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 07:48:20 PST 2026


================
@@ -48,7 +48,17 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, uint64_t Address,
                                        StringRef Annot,
                                        const MCSubtargetInfo &STI,
                                        raw_ostream &OS) {
+
+  unsigned TypeOperand = 0;
+  unsigned TableOperand = 1;
   switch (MI->getOpcode()) {
+  case WebAssembly::CALL_INDIRECT: {
+    unsigned NumDefs = MI->getOperand(0).getImm();
+    TypeOperand = NumDefs + 1;
+    TableOperand = NumDefs + 2;
+    [[fallthrough]];
+  }
+  case WebAssembly::RET_CALL_INDIRECT:
----------------
ParkHanbum wrote:

Yes, I agree. However, it appears RET_CALL_INDIRECT does not have NumDefs. In the case of RET_CALL_INDIRECT, a crash occurs during the process of referencing NumDefs.

I've attached the log below.

```
$ /home/m/wasm32/bin/llc < t.ll -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mcpu=mvp -mattr=+tail-call -mtriple=wasm32--
        .file   "<stdin>"
        .tabletype      __indirect_function_table, funcref
        .functype       indirect_musttail (i32, i32, i32) -> (i32)
        .section        .text.indirect_musttail,"",@
        .globl  indirect_musttail               # -- Begin function indirect_musttail
        .type   indirect_musttail, at function
indirect_musttail:                      # @indirect_musttail
        .functype       indirect_musttail (i32, i32, i32) -> (i32)
# %bb.0:
--- Debugging printInst ---
Opcode: 1622
Full Instruction: <MCInst 1622 <MCOperand Expr:.Ltypeindex0@<variant 7>> <MCOperand Imm:0> <MCOperand Reg:0> <MCOperand Reg:1> <MCOperand Reg:2> <MCOperand Reg:0>>
Operand 0 is Imm? No
---------------------------
llc: /home/m/llvm/llvm/include/llvm/MC/MCInst.h:85: int64_t llvm::MCOperand::getImm() const: Assertion `isImm() && "This is not an immediate"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: /home/m/wasm32/bin/llc -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mcpu=mvp -mattr=+tail-call -mtriple=wasm32--
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'WebAssembly Assembly Printer' on function '@indirect_musttail'
 #0 0x000056333b033530 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/m/wasm32/bin/llc+0x41d6530)
 #1 0x000056333b03020f llvm::sys::RunSignalHandlers() (/home/m/wasm32/bin/llc+0x41d320f)
 #2 0x000056333b030362 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007fd93c6ae520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fd93c7029fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fd93c7029fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fd93c7029fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fd93c6ae476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fd93c6947f3 abort ./stdlib/abort.c:81:7
 #9 0x00007fd93c69471b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007fd93c6a5e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00005633397d48e6 llvm::WebAssemblyInstPrinter::printInst(llvm::MCInst const*, unsigned long, llvm::StringRef, llvm::MCSubtargetInfo const&, llvm::raw_ostream&) (/home/m/wasm32/bin/llc+0x29778e6)
```

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


More information about the llvm-commits mailing list