diff --git a/llvm/lib/CodeGen/MIRVRegNamerUtils.cpp b/llvm/lib/CodeGen/MIRVRegNamerUtils.cpp --- a/llvm/lib/CodeGen/MIRVRegNamerUtils.cpp +++ b/llvm/lib/CodeGen/MIRVRegNamerUtils.cpp @@ -50,23 +50,17 @@ std::string S; raw_string_ostream OS(S); - // Gets a hashable artifact from a given MachineOperand (ie an unsigned). - auto GetHashableMO = [this](const MachineOperand &MO) -> unsigned { - if (MO.isImm()) - return MO.getImm(); - if (MO.isTargetIndex()) - return MO.getOffset() | (MO.getTargetFlags() << 16); - if (MO.isReg() && Register::isVirtualRegister(MO.getReg())) - return MRI.getVRegDef(MO.getReg())->getOpcode(); - if (MO.isReg()) - return MO.getReg(); - // TODO: - // We could explicitly handle all the types of the MachineOperand, - // here but we can just return a common number until we find a - // compelling test case where this is bad. The only side effect here - // is contributing to a hash collision but there's enough information - // (Opcodes,other registers etc) that this will likely not be a problem. - return 0; + // Gets a hashable artifact from a given MachineOperand (ie an unsigned). This + // used to be the vreg/physreg number or the immediate value, but various + // MachineOperand types used to be limited to just immediates, vregs/physregs, + // and Target Indices. This still misses a lot of artifacts like the MO type, + // the target flags for the MO, as well as a lot of the other operand types + // where we used to just return 0. Instead, it makes sense to leverage the + // existing MachineOperand hashing function and just has the combine range of + // those hashes. We should have fewer collisions then and maybe we can even + // eventually drop the collision handling code. + auto GetHashableMO = [](const MachineOperand &MO) { + return llvm::hash_value(MO); }; SmallVector MIOperands = {MI.getOpcode(), MI.getFlags()};