[PATCH] D102978: [WebAssembly] Add TargetInstrInfo::getCalleeOperand
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 24 23:49:35 PDT 2021
aheejin added a comment.
This happened to uncover a long-existing bug in `WebAssembly::getCalleeOp`. For indirect calls it returns <https://github.com/llvm/llvm-project/blob/bf77317049a880af541e31ba7ea43cb229ee4c0f/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp#L90-L94> `MI.getOperand(MI.getNumOperands() - 1)`, but in the presence of implicit operands, most of the time it returns an incorrect operand. For example:
%37:i32 = CALL_INDIRECT 0, 0, %55:i32, %38:i32, %54:i32, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def $value_stack, implicit $value_stack, debug-location !39; system/lib/libc/musl/src/stdlib/bsearch.c:9:10
The callee operand is `%54` here, but this returns `implicit $value_stack`. The should have used `MI.getNumExplicitOperand()` instead. This has not been a problem so far because this utility function has been used only from a few places and all of them only cared about direct calls.
This fixes this bug and adds a test for `call_indirect` too.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102978/new/
https://reviews.llvm.org/D102978
More information about the llvm-commits
mailing list