mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-09 14:03:09 +00:00
IR: Separate out recalculateHash(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225655 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7826807958
commit
6205b21cf5
@ -731,6 +731,7 @@ class GenericMDNode : public MDNode {
|
|||||||
~GenericMDNode();
|
~GenericMDNode();
|
||||||
|
|
||||||
void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
|
void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
|
||||||
|
void recalculateHash();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \brief Get the hash, if any.
|
/// \brief Get the hash, if any.
|
||||||
|
@ -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() {
|
void MDNode::dropAllReferences() {
|
||||||
for (unsigned I = 0, E = NumOperands; I != E; ++I)
|
for (unsigned I = 0, E = NumOperands; I != E; ++I)
|
||||||
setOperand(I, nullptr);
|
setOperand(I, nullptr);
|
||||||
@ -545,18 +557,8 @@ void GenericMDNode::handleChangedOperand(void *Ref, Metadata *New) {
|
|||||||
return;
|
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.
|
// Re-unique the node.
|
||||||
|
recalculateHash();
|
||||||
GenericMDNodeInfo::KeyTy Key(this);
|
GenericMDNodeInfo::KeyTy Key(this);
|
||||||
auto I = Store.find_as(Key);
|
auto I = Store.find_as(Key);
|
||||||
if (I == Store.end()) {
|
if (I == Store.end()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user