Skip to content

Commit 9a547e7

Browse files
committed
[StableHashing] Hash vregs with multiple defs
This allows stableHashValue to be used on Machine IR that is not in SSA form. Differential Revision: https://reviews.llvm.org/D120121
1 parent 722ad3c commit 9a547e7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/CodeGen/MachineStableHash.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
6464
case MachineOperand::MO_Register:
6565
if (Register::isVirtualRegister(MO.getReg())) {
6666
const MachineRegisterInfo &MRI = MO.getParent()->getMF()->getRegInfo();
67-
return MRI.getVRegDef(MO.getReg())->getOpcode();
67+
SmallVector<unsigned> DefOpcodes;
68+
for (auto &Def : MRI.def_instructions(MO.getReg()))
69+
DefOpcodes.push_back(Def.getOpcode());
70+
return hash_combine_range(DefOpcodes.begin(), DefOpcodes.end());
6871
}
6972

7073
// Register operands don't have target flags.

0 commit comments

Comments
 (0)