[llvm] r225655 - IR: Separate out recalculateHash(), NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jan 12 11:16:34 PST 2015
Author: dexonsmith
Date: Mon Jan 12 13:16:34 2015
New Revision: 225655
URL: http://llvm.org/viewvc/llvm-project?rev=225655&view=rev
Log:
IR: Separate out recalculateHash(), NFC
Modified:
llvm/trunk/include/llvm/IR/Metadata.h
llvm/trunk/lib/IR/Metadata.cpp
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=225655&r1=225654&r2=225655&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Mon Jan 12 13:16:34 2015
@@ -731,6 +731,7 @@ class GenericMDNode : public MDNode {
~GenericMDNode();
void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
+ void recalculateHash();
public:
/// \brief Get the hash, if any.
Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=225655&r1=225654&r2=225655&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Mon Jan 12 13:16:34 2015
@@ -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
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()) {
More information about the llvm-commits
mailing list