Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] Use stable_hash_combine instead of hash_combine #105619

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions llvm/lib/CodeGen/MachineStableHash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
case MachineOperand::MO_Register:
if (MO.getReg().isVirtual()) {
const MachineRegisterInfo &MRI = MO.getParent()->getMF()->getRegInfo();
SmallVector<unsigned> DefOpcodes;
SmallVector<stable_hash> DefOpcodes;
for (auto &Def : MRI.def_instructions(MO.getReg()))
DefOpcodes.push_back(Def.getOpcode());
return hash_combine_range(DefOpcodes.begin(), DefOpcodes.end());
return stable_hash_combine_range(DefOpcodes.begin(), DefOpcodes.end());
}

// Register operands don't have target flags.
Expand All @@ -80,7 +80,7 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
: MO.getFPImm()->getValueAPF().bitcastToAPInt();
auto ValHash =
stable_hash_combine_array(Val.getRawData(), Val.getNumWords());
return hash_combine(MO.getType(), MO.getTargetFlags(), ValHash);
return stable_hash_combine(MO.getType(), MO.getTargetFlags(), ValHash);
}

case MachineOperand::MO_MachineBasicBlock:
Expand Down Expand Up @@ -112,8 +112,8 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
MO.getIndex());

case MachineOperand::MO_ExternalSymbol:
return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getOffset(),
xxh3_64bits(MO.getSymbolName()));
return stable_hash_combine(MO.getType(), MO.getTargetFlags(),
MO.getOffset(), xxh3_64bits(MO.getSymbolName()));

case MachineOperand::MO_RegisterMask:
case MachineOperand::MO_RegisterLiveOut: {
Expand All @@ -126,15 +126,16 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
const uint32_t *RegMask = MO.getRegMask();
std::vector<llvm::stable_hash> RegMaskHashes(RegMask,
RegMask + RegMaskSize);
return hash_combine(MO.getType(), MO.getTargetFlags(),
stable_hash_combine_array(RegMaskHashes.data(),
RegMaskHashes.size()));
return stable_hash_combine(
MO.getType(), MO.getTargetFlags(),
stable_hash_combine_array(RegMaskHashes.data(),
RegMaskHashes.size()));
}
}
}

assert(0 && "MachineOperand not associated with any MachineFunction");
return hash_combine(MO.getType(), MO.getTargetFlags());
return stable_hash_combine(MO.getType(), MO.getTargetFlags());
}

case MachineOperand::MO_ShuffleMask: {
Expand All @@ -144,14 +145,15 @@ stable_hash llvm::stableHashValue(const MachineOperand &MO) {
MO.getShuffleMask(), std::back_inserter(ShuffleMaskHashes),
[](int S) -> llvm::stable_hash { return llvm::stable_hash(S); });

return hash_combine(MO.getType(), MO.getTargetFlags(),
stable_hash_combine_array(ShuffleMaskHashes.data(),
ShuffleMaskHashes.size()));
return stable_hash_combine(
MO.getType(), MO.getTargetFlags(),
stable_hash_combine_array(ShuffleMaskHashes.data(),
ShuffleMaskHashes.size()));
}
case MachineOperand::MO_MCSymbol: {
auto SymbolName = MO.getMCSymbol()->getName();
return hash_combine(MO.getType(), MO.getTargetFlags(),
xxh3_64bits(SymbolName));
return stable_hash_combine(MO.getType(), MO.getTargetFlags(),
xxh3_64bits(SymbolName));
}
case MachineOperand::MO_CFIIndex:
return stable_hash_combine(MO.getType(), MO.getTargetFlags(),
Expand Down
Loading