IR: Separate out recalculateHash(), NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 12 Jan 2015 19:16:34 +0000 (19:16 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 12 Jan 2015 19:16:34 +0000 (19:16 +0000)
llvm-svn: 225655

llvm/include/llvm/IR/Metadata.h
llvm/lib/IR/Metadata.cpp

index d868c4b..8033a17 100644 (file)
@@ -731,6 +731,7 @@ class GenericMDNode : public MDNode {
   ~GenericMDNode();
 
   void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
+  void recalculateHash();
 
 public:
   /// \brief Get the hash, if any.
index f303b7d..1ae9a96 100644 (file)
@@ -484,6 +484,18 @@ void GenericMDNode::resolveCycles() {
   }
 }
 
+void GenericMDNode::recalculateHash() {
+  setHash(hash_combine_range(op_begin(), op_end()));
+#ifndef NDEBUG
+  {
+    SmallVector<Metadata *, 8> MDs(op_begin(), op_end());
+    unsigned RawHash = hash_combine_range(MDs.begin(), MDs.end());
+    assert(getHash() == RawHash &&
+           "Expected hash of MDOperand to equal hash of Metadata*");
+  }
+#endif
+}
+
 void MDNode::dropAllReferences() {
   for (unsigned I = 0, E = NumOperands; I != E; ++I)
     setOperand(I, nullptr);
@@ -545,18 +557,8 @@ void GenericMDNode::handleChangedOperand(void *Ref, Metadata *New) {
     return;
   }
 
-  // Re-calculate the hash.
-  setHash(hash_combine_range(op_begin(), op_end()));
-#ifndef NDEBUG
-  {
-    SmallVector<Metadata *, 8> MDs(op_begin(), op_end());
-    unsigned RawHash = hash_combine_range(MDs.begin(), MDs.end());
-    assert(getHash() == RawHash &&
-           "Expected hash of MDOperand to equal hash of Metadata*");
-  }
-#endif
-
   // Re-unique the node.
+  recalculateHash();
   GenericMDNodeInfo::KeyTy Key(this);
   auto I = Store.find_as(Key);
   if (I == Store.end()) {