Skip to content

Commit 7b1bb2b

Browse files
committed
[Passes] Switch to xxh3_64bits
FNV is slow and the name StableHashing.h might be misleading. Just use xxh3_64bits, which has been adopted in many places.
1 parent 4ed543d commit 7b1bb2b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "llvm/Passes/StandardInstrumentations.h"
1616
#include "llvm/ADT/Any.h"
17-
#include "llvm/ADT/StableHashing.h"
1817
#include "llvm/ADT/StringRef.h"
1918
#include "llvm/Analysis/CallGraphSCCPass.h"
2019
#include "llvm/Analysis/LazyCallGraph.h"
@@ -44,6 +43,7 @@
4443
#include "llvm/Support/Regex.h"
4544
#include "llvm/Support/Signals.h"
4645
#include "llvm/Support/raw_ostream.h"
46+
#include "llvm/Support/xxhash.h"
4747
#include <unordered_map>
4848
#include <unordered_set>
4949
#include <utility>
@@ -753,28 +753,27 @@ static SmallString<32> getIRFileDisplayName(Any IR) {
753753
SmallString<32> Result;
754754
raw_svector_ostream ResultStream(Result);
755755
const Module *M = unwrapModule(IR);
756-
stable_hash NameHash = stable_hash_combine_string(M->getName());
757-
unsigned int MaxHashWidth = sizeof(stable_hash) * 8 / 4;
756+
uint64_t NameHash = xxh3_64bits(M->getName());
757+
unsigned MaxHashWidth = sizeof(uint64_t) * 2;
758758
write_hex(ResultStream, NameHash, HexPrintStyle::Lower, MaxHashWidth);
759759
if (unwrapIR<Module>(IR)) {
760760
ResultStream << "-module";
761761
} else if (const auto *F = unwrapIR<Function>(IR)) {
762762
ResultStream << "-function-";
763-
stable_hash FunctionNameHash = stable_hash_combine_string(F->getName());
763+
auto FunctionNameHash = xxh3_64bits(F->getName());
764764
write_hex(ResultStream, FunctionNameHash, HexPrintStyle::Lower,
765765
MaxHashWidth);
766766
} else if (const auto *C = unwrapIR<LazyCallGraph::SCC>(IR)) {
767767
ResultStream << "-scc-";
768-
stable_hash SCCNameHash = stable_hash_combine_string(C->getName());
768+
auto SCCNameHash = xxh3_64bits(C->getName());
769769
write_hex(ResultStream, SCCNameHash, HexPrintStyle::Lower, MaxHashWidth);
770770
} else if (const auto *L = unwrapIR<Loop>(IR)) {
771771
ResultStream << "-loop-";
772-
stable_hash LoopNameHash = stable_hash_combine_string(L->getName());
772+
auto LoopNameHash = xxh3_64bits(L->getName());
773773
write_hex(ResultStream, LoopNameHash, HexPrintStyle::Lower, MaxHashWidth);
774774
} else if (const auto *MF = unwrapIR<MachineFunction>(IR)) {
775775
ResultStream << "-machine-function-";
776-
stable_hash MachineFunctionNameHash =
777-
stable_hash_combine_string(MF->getName());
776+
auto MachineFunctionNameHash = xxh3_64bits(MF->getName());
778777
write_hex(ResultStream, MachineFunctionNameHash, HexPrintStyle::Lower,
779778
MaxHashWidth);
780779
} else {

0 commit comments

Comments
 (0)