Skip to content

Commit

Permalink
[Passes] Switch to xxh3_64bits
Browse files Browse the repository at this point in the history
FNV is slow and the name StableHashing.h might be misleading. Just use
xxh3_64bits, which has been adopted in many places.
  • Loading branch information
MaskRay committed Jul 25, 2024
1 parent 4ed543d commit 7b1bb2b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions llvm/lib/Passes/StandardInstrumentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/ADT/Any.h"
#include "llvm/ADT/StableHashing.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/LazyCallGraph.h"
Expand Down Expand Up @@ -44,6 +43,7 @@
#include "llvm/Support/Regex.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/xxhash.h"
#include <unordered_map>
#include <unordered_set>
#include <utility>
Expand Down Expand Up @@ -753,28 +753,27 @@ static SmallString<32> getIRFileDisplayName(Any IR) {
SmallString<32> Result;
raw_svector_ostream ResultStream(Result);
const Module *M = unwrapModule(IR);
stable_hash NameHash = stable_hash_combine_string(M->getName());
unsigned int MaxHashWidth = sizeof(stable_hash) * 8 / 4;
uint64_t NameHash = xxh3_64bits(M->getName());
unsigned MaxHashWidth = sizeof(uint64_t) * 2;
write_hex(ResultStream, NameHash, HexPrintStyle::Lower, MaxHashWidth);
if (unwrapIR<Module>(IR)) {
ResultStream << "-module";
} else if (const auto *F = unwrapIR<Function>(IR)) {
ResultStream << "-function-";
stable_hash FunctionNameHash = stable_hash_combine_string(F->getName());
auto FunctionNameHash = xxh3_64bits(F->getName());
write_hex(ResultStream, FunctionNameHash, HexPrintStyle::Lower,
MaxHashWidth);
} else if (const auto *C = unwrapIR<LazyCallGraph::SCC>(IR)) {
ResultStream << "-scc-";
stable_hash SCCNameHash = stable_hash_combine_string(C->getName());
auto SCCNameHash = xxh3_64bits(C->getName());
write_hex(ResultStream, SCCNameHash, HexPrintStyle::Lower, MaxHashWidth);
} else if (const auto *L = unwrapIR<Loop>(IR)) {
ResultStream << "-loop-";
stable_hash LoopNameHash = stable_hash_combine_string(L->getName());
auto LoopNameHash = xxh3_64bits(L->getName());
write_hex(ResultStream, LoopNameHash, HexPrintStyle::Lower, MaxHashWidth);
} else if (const auto *MF = unwrapIR<MachineFunction>(IR)) {
ResultStream << "-machine-function-";
stable_hash MachineFunctionNameHash =
stable_hash_combine_string(MF->getName());
auto MachineFunctionNameHash = xxh3_64bits(MF->getName());
write_hex(ResultStream, MachineFunctionNameHash, HexPrintStyle::Lower,
MaxHashWidth);
} else {
Expand Down

0 comments on commit 7b1bb2b

Please sign in to comment.