diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h --- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h +++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h @@ -1975,6 +1975,11 @@ return OptLevel >= CodeGenOpt::Aggressive ? 4 : 2; } + /// Returns the callee operand from the given \p MI. + virtual const MachineOperand &getCalleeOperand(const MachineInstr &MI) const { + return MI.getOperand(0); + } + private: mutable std::unique_ptr Formatter; unsigned CallFrameSetupOpcode, CallFrameDestroyOpcode; diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -938,7 +938,7 @@ // If this is a direct call, find the callee's subprogram. // In the case of an indirect call find the register that holds // the callee. - const MachineOperand &CalleeOp = MI.getOperand(0); + const MachineOperand &CalleeOp = TII->getCalleeOperand(MI); if (!CalleeOp.isGlobal() && !CalleeOp.isReg()) continue; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.h b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.h --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.h @@ -68,6 +68,8 @@ ArrayRef> getSerializableTargetIndices() const override; + + const MachineOperand &getCalleeOperand(const MachineInstr &MI) const override; }; } // end namespace llvm diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp @@ -14,6 +14,7 @@ #include "WebAssemblyInstrInfo.h" #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" +#include "Utils/WebAssemblyUtilities.h" #include "WebAssembly.h" #include "WebAssemblyMachineFunctionInfo.h" #include "WebAssemblySubtarget.h" @@ -214,3 +215,8 @@ {WebAssembly::TI_LOCAL_INDIRECT, "wasm-local-indirect"}}; return makeArrayRef(TargetIndices); } + +const MachineOperand & +WebAssemblyInstrInfo::getCalleeOperand(const MachineInstr &MI) const { + return WebAssembly::getCalleeOp(MI); +} diff --git a/llvm/test/CodeGen/WebAssembly/stackified-debug.ll b/llvm/test/CodeGen/WebAssembly/stackified-debug.ll --- a/llvm/test/CodeGen/WebAssembly/stackified-debug.ll +++ b/llvm/test/CodeGen/WebAssembly/stackified-debug.ll @@ -1,4 +1,5 @@ ; RUN: llc -verify-machineinstrs < %s | FileCheck %s +; RUN: llc --debug < %s ; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefix DWARF ; Input C code: