[llvm-commits] [llvm] r152200 - /llvm/trunk/lib/VMCore/ConstantsContext.h

Chandler Carruth chandlerc at gmail.com
Tue Mar 6 19:22:32 PST 2012


Author: chandlerc
Date: Tue Mar  6 21:22:32 2012
New Revision: 152200

URL: http://llvm.org/viewvc/llvm-project?rev=152200&view=rev
Log:
Switch this code to use hash_combine_range rather than incremental calls
to hash_combine. One of the interfaces could already do this, and the
other can just use a small buffer. This is a much more efficient way to
use the hash_combine interface, although I don't have any particular
benchmark where this code was hot, so I can't measure much of an impact.
It at least doesn't slow anything down.

Modified:
    llvm/trunk/lib/VMCore/ConstantsContext.h

Modified: llvm/trunk/lib/VMCore/ConstantsContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantsContext.h?rev=152200&r1=152199&r2=152200&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantsContext.h (original)
+++ llvm/trunk/lib/VMCore/ConstantsContext.h Tue Mar  6 21:22:32 2012
@@ -657,20 +657,18 @@
       return ConstantClassInfo::getTombstoneKey();
     }
     static unsigned getHashValue(const ConstantClass *CP) {
-      hash_code code = hash_value(CP->getType());
+      SmallVector<Constant*, 8> CPOperands;
+      CPOperands.reserve(CP->getNumOperands());
       for (unsigned I = 0, E = CP->getNumOperands(); I < E; ++I)
-        code = hash_combine(code, hash_value(CP->getOperand(I)));
-      return code;
+        CPOperands.push_back(CP->getOperand(I));
+      return getHashValue(LookupKey(CP->getType(), CPOperands));
     }
     static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
       return LHS == RHS;
     }
     static unsigned getHashValue(const LookupKey &Val) {
-      hash_code code = hash_value(Val.first);
-      for (Operands::const_iterator
-           I = Val.second.begin(), E = Val.second.end(); I != E; ++I)
-        code = hash_combine(code, hash_value(*I));
-      return code;
+      return hash_combine(Val.first, hash_combine_range(Val.second.begin(),
+                                                        Val.second.end()));
     }
     static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
       if (RHS == getEmptyKey() || RHS == getTombstoneKey())





More information about the llvm-commits mailing list