Index: lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp +++ lib/Target/WebAssembly/WebAssemblyArgumentMove.cpp @@ -78,7 +78,7 @@ // Look for the first NonArg instruction. for (MachineInstr &MI : EntryMBB) { - if (!WebAssembly::isArgument(MI)) { + if (!WebAssembly::isArgument(MI.getOpcode())) { InsertPt = MI; break; } @@ -87,7 +87,7 @@ // Now move any argument instructions later in the block // to before our first NonArg instruction. for (MachineInstr &MI : llvm::make_range(InsertPt, EntryMBB.end())) { - if (WebAssembly::isArgument(MI)) { + if (WebAssembly::isArgument(MI.getOpcode())) { EntryMBB.insert(InsertPt, MI.removeFromParent()); Changed = true; } Index: lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -894,7 +894,7 @@ // We wrap up the current range when we see a marker even if we haven't // finished a BB. - if (RangeEnd && WebAssembly::isMarker(MI)) { + if (RangeEnd && WebAssembly::isMarker(MI.getOpcode())) { NeedAppendixBlock = true; // Record the range. nullptr here means the unwind destination is the // caller. Index: lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -205,7 +205,7 @@ E = MF.begin()->end(); I != E;) { MachineInstr &MI = *I++; - if (!WebAssembly::isArgument(MI)) + if (!WebAssembly::isArgument(MI.getOpcode())) break; unsigned Reg = MI.getOperand(0).getReg(); assert(!MFI.isVRegStackified(Reg)); @@ -227,7 +227,7 @@ for (MachineBasicBlock &MBB : MF) { for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E;) { MachineInstr &MI = *I++; - assert(!WebAssembly::isArgument(MI)); + assert(!WebAssembly::isArgument(MI.getOpcode())); if (MI.isDebugInstr() || MI.isLabel()) continue; @@ -235,7 +235,7 @@ // Replace tee instructions with local.tee. The difference is that tee // instructions have two defs, while local.tee instructions have one def // and an index of a local to write to. - if (WebAssembly::isTee(MI)) { + if (WebAssembly::isTee(MI.getOpcode())) { assert(MFI.isVRegStackified(MI.getOperand(0).getReg())); assert(!MFI.isVRegStackified(MI.getOperand(1).getReg())); unsigned OldReg = MI.getOperand(2).getReg(); @@ -356,7 +356,7 @@ } // Coalesce and eliminate COPY instructions. - if (WebAssembly::isCopy(MI)) { + if (WebAssembly::isCopy(MI.getOpcode())) { MRI.replaceRegWith(MI.getOperand(1).getReg(), MI.getOperand(0).getReg()); MI.eraseFromParent(); Index: lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp +++ lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp @@ -164,7 +164,8 @@ auto &MRI = MF.getRegInfo(); auto InsertPt = MBB.begin(); - while (InsertPt != MBB.end() && WebAssembly::isArgument(*InsertPt)) + while (InsertPt != MBB.end() && + WebAssembly::isArgument(InsertPt->getOpcode())) ++InsertPt; DebugLoc DL; Index: lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp +++ lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp @@ -221,7 +221,7 @@ // call_indirect instructions have a callee operand at the end which // doesn't count as a param. - if (WebAssembly::isCallIndirect(*MI)) + if (WebAssembly::isCallIndirect(MI->getOpcode())) Params.pop_back(); auto *WasmSym = cast(Sym); Index: lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp +++ lib/Target/WebAssembly/WebAssemblyPrepareForLiveIntervals.cpp @@ -64,7 +64,7 @@ // Test whether the given register has an ARGUMENT def. static bool hasArgumentDef(unsigned Reg, const MachineRegisterInfo &MRI) { for (const auto &Def : MRI.def_instructions(Reg)) - if (WebAssembly::isArgument(Def)) + if (WebAssembly::isArgument(Def.getOpcode())) return true; return false; } @@ -114,7 +114,7 @@ // liveness reflects the fact that these really are live-in values. for (auto MII = Entry.begin(), MIE = Entry.end(); MII != MIE;) { MachineInstr &MI = *MII++; - if (WebAssembly::isArgument(MI)) { + if (WebAssembly::isArgument(MI.getOpcode())) { MI.removeFromParent(); Entry.insert(Entry.begin(), &MI); } Index: lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp +++ lib/Target/WebAssembly/WebAssemblyRegNumbering.cpp @@ -72,7 +72,7 @@ // variables. Assign the numbers for them first. MachineBasicBlock &EntryMBB = MF.front(); for (MachineInstr &MI : EntryMBB) { - if (!WebAssembly::isArgument(MI)) + if (!WebAssembly::isArgument(MI.getOpcode())) break; int64_t Imm = MI.getOperand(1).getImm(); Index: lib/Target/WebAssembly/WebAssemblyRegStackify.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -252,7 +252,7 @@ // Analyze calls. if (MI.isCall()) { - unsigned CalleeOpNo = WebAssembly::getCalleeOpNo(MI); + unsigned CalleeOpNo = WebAssembly::getCalleeOpNo(MI.getOpcode()); queryCallee(MI, CalleeOpNo, Read, Write, Effects, StackPointer); } } @@ -826,7 +826,7 @@ // Argument instructions represent live-in registers and not real // instructions. - if (WebAssembly::isArgument(*Def)) + if (WebAssembly::isArgument(Def->getOpcode())) continue; // Currently catch's return value register cannot be stackified, because Index: lib/Target/WebAssembly/WebAssemblyUtilities.h =================================================================== --- lib/Target/WebAssembly/WebAssemblyUtilities.h +++ lib/Target/WebAssembly/WebAssemblyUtilities.h @@ -23,18 +23,19 @@ namespace WebAssembly { -bool isArgument(const MachineInstr &MI); -bool isCopy(const MachineInstr &MI); -bool isTee(const MachineInstr &MI); +bool isArgument(unsigned Opc); +bool isCopy(unsigned Opc); +bool isTee(unsigned Opc); +bool isCallDirect(unsigned Opc); +bool isCallIndirect(unsigned Opc); +bool isMarker(unsigned Opc); + bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI); -bool isCallDirect(const MachineInstr &MI); -bool isCallIndirect(const MachineInstr &MI); -bool isMarker(const MachineInstr &MI); bool mayThrow(const MachineInstr &MI); /// Returns the operand number of a callee, assuming the argument is a call /// instruction. -unsigned getCalleeOpNo(const MachineInstr &MI); +unsigned getCalleeOpNo(unsigned Opc); // Exception-related function names extern const char *const ClangCallTerminateFn; Index: lib/Target/WebAssembly/WebAssemblyUtilities.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyUtilities.cpp +++ lib/Target/WebAssembly/WebAssemblyUtilities.cpp @@ -24,8 +24,8 @@ const char *const WebAssembly::PersonalityWrapperFn = "_Unwind_Wasm_CallPersonality"; -bool WebAssembly::isArgument(const MachineInstr &MI) { - switch (MI.getOpcode()) { +bool WebAssembly::isArgument(unsigned Opc) { + switch (Opc) { case WebAssembly::ARGUMENT_i32: case WebAssembly::ARGUMENT_i32_S: case WebAssembly::ARGUMENT_i64: @@ -52,8 +52,8 @@ } } -bool WebAssembly::isCopy(const MachineInstr &MI) { - switch (MI.getOpcode()) { +bool WebAssembly::isCopy(unsigned Opc) { + switch (Opc) { case WebAssembly::COPY_I32: case WebAssembly::COPY_I32_S: case WebAssembly::COPY_I64: @@ -72,8 +72,8 @@ } } -bool WebAssembly::isTee(const MachineInstr &MI) { - switch (MI.getOpcode()) { +bool WebAssembly::isTee(unsigned Opc) { + switch (Opc) { case WebAssembly::TEE_I32: case WebAssembly::TEE_I32_S: case WebAssembly::TEE_I64: @@ -103,8 +103,8 @@ MFI.isVRegStackified(Reg); } -bool WebAssembly::isCallDirect(const MachineInstr &MI) { - switch (MI.getOpcode()) { +bool WebAssembly::isCallDirect(unsigned Opc) { + switch (Opc) { case WebAssembly::CALL_VOID: case WebAssembly::CALL_VOID_S: case WebAssembly::CALL_i32: @@ -137,8 +137,8 @@ } } -bool WebAssembly::isCallIndirect(const MachineInstr &MI) { - switch (MI.getOpcode()) { +bool WebAssembly::isCallIndirect(unsigned Opc) { + switch (Opc) { case WebAssembly::CALL_INDIRECT_VOID: case WebAssembly::CALL_INDIRECT_VOID_S: case WebAssembly::CALL_INDIRECT_i32: @@ -171,8 +171,8 @@ } } -unsigned WebAssembly::getCalleeOpNo(const MachineInstr &MI) { - switch (MI.getOpcode()) { +unsigned WebAssembly::getCalleeOpNo(unsigned Opc) { + switch (Opc) { case WebAssembly::CALL_VOID: case WebAssembly::CALL_VOID_S: case WebAssembly::CALL_INDIRECT_VOID: @@ -232,8 +232,8 @@ } } -bool WebAssembly::isMarker(const MachineInstr &MI) { - switch (MI.getOpcode()) { +bool WebAssembly::isMarker(unsigned Opc) { + switch (Opc) { case WebAssembly::BLOCK: case WebAssembly::BLOCK_S: case WebAssembly::END_BLOCK: @@ -260,12 +260,12 @@ case WebAssembly::RETHROW_S: return true; } - if (isCallIndirect(MI)) + if (isCallIndirect(MI.getOpcode())) return true; if (!MI.isCall()) return false; - const MachineOperand &MO = MI.getOperand(getCalleeOpNo(MI)); + const MachineOperand &MO = MI.getOperand(getCalleeOpNo(MI.getOpcode())); assert(MO.isGlobal()); const auto *F = dyn_cast(MO.getGlobal()); if (!F)