diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-03-01 23:18:44 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-03-01 23:18:44 +0000 |
commit | 93cffd2fb53752f3083384bfd5e740f97341bd3a (patch) | |
tree | 03c5e2deb2b5aa72850b06dfeb7cfdb75b4fe125 /llvm/lib/Support/FoldingSet.cpp | |
parent | b18744943552aae4da5ed4034baf5436b8970178 (diff) | |
download | bcm5719-llvm-93cffd2fb53752f3083384bfd5e740f97341bd3a.tar.gz bcm5719-llvm-93cffd2fb53752f3083384bfd5e740f97341bd3a.zip |
Switch FoldingSet over to the new hashing infrastructure. We might want
to do more invasive refactoring here to get FoldingSet to use size_t or
even hash_code directly, but for now this is a good first step to remove
Yet Another Hashing Algorithm from LLVM.
llvm-svn: 151859
Diffstat (limited to 'llvm/lib/Support/FoldingSet.cpp')
-rw-r--r-- | llvm/lib/Support/FoldingSet.cpp | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp index 17b827132f5..e029970b586 100644 --- a/llvm/lib/Support/FoldingSet.cpp +++ b/llvm/lib/Support/FoldingSet.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/Hashing.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" @@ -29,24 +30,7 @@ using namespace llvm; /// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, /// used to lookup the node in the FoldingSetImpl. unsigned FoldingSetNodeIDRef::ComputeHash() const { - // This is adapted from SuperFastHash by Paul Hsieh. - unsigned Hash = static_cast<unsigned>(Size); - for (const unsigned *BP = Data, *E = BP+Size; BP != E; ++BP) { - unsigned Data = *BP; - Hash += Data & 0xFFFF; - unsigned Tmp = ((Data >> 16) << 11) ^ Hash; - Hash = (Hash << 16) ^ Tmp; - Hash += Hash >> 11; - } - - // Force "avalanching" of final 127 bits. - Hash ^= Hash << 3; - Hash += Hash >> 5; - Hash ^= Hash << 4; - Hash += Hash >> 17; - Hash ^= Hash << 25; - Hash += Hash >> 6; - return Hash; + return static_cast<unsigned>(hash_combine_range(Data, Data+Size)); } bool FoldingSetNodeIDRef::operator==(FoldingSetNodeIDRef RHS) const { |