Skip to content

Commit 891ce5b

Browse files
committed
[NFC][StructuralHash] Use hash_code
1 parent 3333e12 commit 891ce5b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/IR/StructuralHash.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ namespace {
1919
// llvm/lib/Transforms/Utils/FunctionComparator.cpp
2020

2121
class StructuralHashImpl {
22-
uint64_t Hash = 0x6acaa36bef8325c5ULL;
22+
hash_code Hash;
2323

24-
void update(uint64_t V) { Hash = hashing::detail::hash_16_bytes(Hash, V); }
24+
template <typename T> void hash(const T &V) { Hash = hash_combine(Hash, V); }
2525

2626
public:
27-
StructuralHashImpl() = default;
27+
StructuralHashImpl() : Hash(4) {}
2828

2929
void update(const Function &F) {
3030
if (F.empty())
3131
return;
3232

33-
update(F.isVarArg());
34-
update(F.arg_size());
33+
hash(F.isVarArg());
34+
hash(F.arg_size());
3535

3636
SmallVector<const BasicBlock *, 8> BBs;
3737
SmallPtrSet<const BasicBlock *, 16> VisitedBBs;
@@ -40,9 +40,9 @@ class StructuralHashImpl {
4040
VisitedBBs.insert(BBs[0]);
4141
while (!BBs.empty()) {
4242
const BasicBlock *BB = BBs.pop_back_val();
43-
update(45798); // Block header
43+
hash(45798); // Block header
4444
for (auto &Inst : *BB)
45-
update(Inst.getOpcode());
45+
hash(Inst.getOpcode());
4646

4747
const Instruction *Term = BB->getTerminator();
4848
for (unsigned i = 0, e = Term->getNumSuccessors(); i != e; ++i) {

0 commit comments

Comments
 (0)