diff options
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r-- | llvm/lib/IR/Metadata.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index f303b7d8a71..1ae9a96fe46 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -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()) { |