summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Metadata.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-19 22:53:18 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-01-19 22:53:18 +0000
commit93e983e70796b047d4a798d23b536ba7ef111565 (patch)
tree9fc593e5628f9fce6a0de4a0d75b76343314a03c /llvm/lib/IR/Metadata.cpp
parentf9d1bc99192da5ace50643bb630ef014bc12cd25 (diff)
downloadbcm5719-llvm-93e983e70796b047d4a798d23b536ba7ef111565.tar.gz
bcm5719-llvm-93e983e70796b047d4a798d23b536ba7ef111565.zip
IR: Extract MDNodeOpsKey, NFC
Make the MDTuple operand hashing logic reusable. llvm-svn: 226519
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r--llvm/lib/IR/Metadata.cpp29
1 files changed, 2 insertions, 27 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index e9265eb96ad..8253a4e6a96 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -515,15 +515,7 @@ void UniquableMDNode::resolveCycles() {
}
void MDTuple::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
+ setHash(MDTupleInfo::KeyTy::calculateHash(this));
}
void MDNode::dropAllReferences() {
@@ -536,23 +528,6 @@ void MDNode::dropAllReferences() {
}
}
-namespace llvm {
-/// \brief Make MDOperand transparent for hashing.
-///
-/// This overload of an implementation detail of the hashing library makes
-/// MDOperand hash to the same value as a \a Metadata pointer.
-///
-/// Note that overloading \a hash_value() as follows:
-///
-/// \code
-/// size_t hash_value(const MDOperand &X) { return hash_value(X.get()); }
-/// \endcode
-///
-/// does not cause MDOperand to be transparent. In particular, a bare pointer
-/// doesn't get hashed before it's combined, whereas \a MDOperand would.
-static const Metadata *get_hashable_data(const MDOperand &X) { return X.get(); }
-}
-
void UniquableMDNode::handleChangedOperand(void *Ref, Metadata *New) {
unsigned Op = static_cast<MDOperand *>(Ref) - op_begin();
assert(Op < getNumOperands() && "Expected valid operand");
@@ -687,7 +662,7 @@ MDTuple *MDTuple::getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
return N;
if (!ShouldCreate)
return nullptr;
- Hash = Key.Hash;
+ Hash = Key.getHash();
} else {
assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
}
OpenPOWER on IntegriCloud