aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2012-03-06 10:43:52 +0000
committerJay Foad <jay.foad@gmail.com>2012-03-06 10:43:52 +0000
commit4e3e5dec1a2a479891b4081c1c715a97fd85644d (patch)
treef3dfa79f1b6c6dd444fb04a3ed172c247356c2ce /lib/VMCore
parentb3ef2230ff3535e763c9cd3ed1146bc8fd7d1d1e (diff)
downloadexternal_llvm-4e3e5dec1a2a479891b4081c1c715a97fd85644d.zip
external_llvm-4e3e5dec1a2a479891b4081c1c715a97fd85644d.tar.gz
external_llvm-4e3e5dec1a2a479891b4081c1c715a97fd85644d.tar.bz2
Change ConstantAggrUniqueMap to use Chandler's new hashing
implementation. Patch by Meador Inge git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantsContext.h45
1 files changed, 9 insertions, 36 deletions
diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h
index a7277f6..7f2198d 100644
--- a/lib/VMCore/ConstantsContext.h
+++ b/lib/VMCore/ConstantsContext.h
@@ -16,6 +16,7 @@
#define LLVM_CONSTANTSCONTEXT_H
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Hashing.h"
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
#include "llvm/Operator.h"
@@ -656,48 +657,20 @@ private:
return ConstantClassInfo::getTombstoneKey();
}
static unsigned getHashValue(const ConstantClass *CP) {
- // This is adapted from SuperFastHash by Paul Hsieh.
- unsigned Hash = TypeClassInfo::getHashValue(CP->getType());
- for (unsigned I = 0, E = CP->getNumOperands(); I < E; ++I) {
- unsigned Data = ConstantInfo::getHashValue(CP->getOperand(I));
- 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;
+ hash_code code = hash_value(CP->getType());
+ for (unsigned I = 0, E = CP->getNumOperands(); I < E; ++I)
+ code = hash_combine(code, hash_value(CP->getOperand(I)));
+ return code;
}
static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
return LHS == RHS;
}
static unsigned getHashValue(const LookupKey &Val) {
- // This is adapted from SuperFastHash by Paul Hsieh.
- unsigned Hash = TypeClassInfo::getHashValue(Val.first);
+ hash_code code = hash_value(Val.first);
for (Operands::const_iterator
- I = Val.second.begin(), E = Val.second.end(); I != E; ++I) {
- unsigned Data = ConstantInfo::getHashValue(*I);
- 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;
+ I = Val.second.begin(), E = Val.second.end(); I != E; ++I)
+ code = hash_combine(code, hash_value(*I));
+ return code;
}
static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
if (RHS == getEmptyKey() || RHS == getTombstoneKey())