This is an archive of the discontinued LLVM Phabricator instance.

[StableHashing] Hash vregs with multiple defs
ClosedPublic

Authored by foad on Feb 18 2022, 5:47 AM.

Details

Summary

This allows stableHashValue to be used on Machine IR that is
not in SSA form.

Diff Detail

Event Timeline

foad created this revision.Feb 18 2022, 5:47 AM
foad requested review of this revision.Feb 18 2022, 5:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2022, 5:47 AM
arsenm added inline comments.Feb 18 2022, 7:07 AM
llvm/lib/CodeGen/MachineStableHash.cpp
69

If this only uses the opcode, won't it collide if you have multiple defs of the same register by the same opcode?

foad added inline comments.Feb 18 2022, 7:18 AM
llvm/lib/CodeGen/MachineStableHash.cpp
69

You'd get collisions anyway if different instructions with the same opcode define the register, but that was presumably by design, to make the hashing more stable somehow. I don't see how having multiple defs with the same opcode makes it any worse.

arsenm accepted this revision.Feb 18 2022, 7:29 AM

LGTM. I guess this is only used for naming anyway right now

This revision is now accepted and ready to land.Feb 18 2022, 7:29 AM

Stable hash was designed to infer the machine instructions that are likely to be identical so that we can optimistically outline them.
I don't have a strong suggestion on how to interpret this in the presence of virtual registers (before RA).
But by taking all their defs into account, it appears the hash is likely to be more unique than before.
Is there any specific use case or reason to enhance this collision?

foad added a comment.Feb 18 2022, 9:19 AM

Is there any specific use case or reason to enhance this collision?

See D120124: I want to use this as a quick hash for MachineFunctions (either before or after SSA, before or after regalloc) to detect which FunctionPasses modify them.

Is there any specific use case or reason to enhance this collision?

See D120124: I want to use this as a quick hash for MachineFunctions (either before or after SSA, before or after regalloc) to detect which FunctionPasses modify them.

Got it. Thanks!

This revision was landed with ongoing or failed builds.Feb 21 2022, 2:39 AM
This revision was automatically updated to reflect the committed changes.