diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp | 19 | 
1 files changed, 18 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp index a237da8154ab..bc2bb4fd6935 100644 --- a/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp +++ b/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp @@ -49,7 +49,7 @@ bool WebAssembly::mayThrow(const MachineInstr &MI) {    if (!MI.isCall())      return false; -  const MachineOperand &MO = MI.getOperand(getCalleeOpNo(MI.getOpcode())); +  const MachineOperand &MO = getCalleeOp(MI);    assert(MO.isGlobal() || MO.isSymbol());    if (MO.isSymbol()) { @@ -79,3 +79,20 @@ bool WebAssembly::mayThrow(const MachineInstr &MI) {    // original LLVm IR? (Even when the callee may throw)    return true;  } + +const MachineOperand &WebAssembly::getCalleeOp(const MachineInstr &MI) { +  switch (MI.getOpcode()) { +  case WebAssembly::CALL: +  case WebAssembly::CALL_S: +  case WebAssembly::RET_CALL: +  case WebAssembly::RET_CALL_S: +    return MI.getOperand(MI.getNumExplicitDefs()); +  case WebAssembly::CALL_INDIRECT: +  case WebAssembly::CALL_INDIRECT_S: +  case WebAssembly::RET_CALL_INDIRECT: +  case WebAssembly::RET_CALL_INDIRECT_S: +    return MI.getOperand(MI.getNumOperands() - 1); +  default: +    llvm_unreachable("Not a call instruction"); +  } +}  | 
