From: Arthur Eubanks Date: Tue, 25 Apr 2023 21:11:49 +0000 (-0700) Subject: [NFC][StructuralHash] Use hash_code X-Git-Tag: upstream/17.0.6~10445 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=891ce5bdceadd938901289c19ce2b0bf34bdfbb9;p=platform%2Fupstream%2Fllvm.git [NFC][StructuralHash] Use hash_code --- diff --git a/llvm/lib/IR/StructuralHash.cpp b/llvm/lib/IR/StructuralHash.cpp index 077f8b6..8fcd337 100644 --- a/llvm/lib/IR/StructuralHash.cpp +++ b/llvm/lib/IR/StructuralHash.cpp @@ -19,19 +19,19 @@ namespace { // llvm/lib/Transforms/Utils/FunctionComparator.cpp class StructuralHashImpl { - uint64_t Hash = 0x6acaa36bef8325c5ULL; + hash_code Hash; - void update(uint64_t V) { Hash = hashing::detail::hash_16_bytes(Hash, V); } + template void hash(const T &V) { Hash = hash_combine(Hash, V); } public: - StructuralHashImpl() = default; + StructuralHashImpl() : Hash(4) {} void update(const Function &F) { if (F.empty()) return; - update(F.isVarArg()); - update(F.arg_size()); + hash(F.isVarArg()); + hash(F.arg_size()); SmallVector BBs; SmallPtrSet VisitedBBs; @@ -40,9 +40,9 @@ public: VisitedBBs.insert(BBs[0]); while (!BBs.empty()) { const BasicBlock *BB = BBs.pop_back_val(); - update(45798); // Block header + hash(45798); // Block header for (auto &Inst : *BB) - update(Inst.getOpcode()); + hash(Inst.getOpcode()); const Instruction *Term = BB->getTerminator(); for (unsigned i = 0, e = Term->getNumSuccessors(); i != e; ++i) {