[PATCH] D158250: [IR] Add more details to StructuralHash
Aiden Grossman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 00:44:02 PDT 2023
aidengrossman added inline comments.
================
Comment at: llvm/lib/IR/StructuralHash.cpp:83-91
+ if (const IntrinsicInst *InstrinsicInstruction =
+ dyn_cast<IntrinsicInst>(&Inst))
+ hash(InstrinsicInstruction->getIntrinsicID());
+ if (const CallInst *CallInstruction = dyn_cast<CallInst>(&Inst))
+ hash(CallInstruction->getCalledFunction()->getName());
+
+ for (unsigned I = 0; I < Inst.getNumOperands(); ++I) {
----------------
nikic wrote:
> This seems like a very random collection of things to add to the hash. Why isn't this just hashing all the operands? That should cover the operand types, the called function and the intrinsic ID.
I was under the impression that it wasn't possible to just hash a value. I can hash the pointer, but I'm not sure that would be correct in all cases (unless everything is uniqued appropriately).
https://github.com/llvm/llvm-project/blob/d9cb76bc4d5e903fe045c58a42fc791d0c70172b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h#L261 implements logic that seems to follow those assumptions (and is a similar implementation to what is here).
Definitely could be that my assumptions are incorrect here though.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158250/new/
https://reviews.llvm.org/D158250
More information about the llvm-commits
mailing list