mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
IR: Stop erasing MDNodes from uniquing sets during teardown
Stop erasing `MDNode`s from the uniquing sets in `LLVMContextImpl` during teardown (in particular, during `UniquableMDNode::~UniquableMDNode()`). Although it's currently feasible, there isn't any clear benefit and it may not be feasible for other subclasses (which don't explicitly store the lookup hash). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225696 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9e3e492f03
commit
d1ec4f037d
@ -722,7 +722,7 @@ protected:
|
|||||||
/// resolveCycles() is called).
|
/// resolveCycles() is called).
|
||||||
UniquableMDNode(LLVMContext &C, unsigned ID, ArrayRef<Metadata *> Vals,
|
UniquableMDNode(LLVMContext &C, unsigned ID, ArrayRef<Metadata *> Vals,
|
||||||
bool AllowRAUW);
|
bool AllowRAUW);
|
||||||
~UniquableMDNode();
|
~UniquableMDNode() {}
|
||||||
|
|
||||||
void storeDistinctInContext();
|
void storeDistinctInContext();
|
||||||
|
|
||||||
@ -767,7 +767,7 @@ class MDTuple : public UniquableMDNode {
|
|||||||
|
|
||||||
MDTuple(LLVMContext &C, ArrayRef<Metadata *> Vals, bool AllowRAUW)
|
MDTuple(LLVMContext &C, ArrayRef<Metadata *> Vals, bool AllowRAUW)
|
||||||
: UniquableMDNode(C, MDTupleKind, Vals, AllowRAUW) {}
|
: UniquableMDNode(C, MDTupleKind, Vals, AllowRAUW) {}
|
||||||
~MDTuple();
|
~MDTuple() { dropAllReferences(); }
|
||||||
|
|
||||||
void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
|
void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
|
||||||
void recalculateHash();
|
void recalculateHash();
|
||||||
|
@ -135,18 +135,16 @@ LLVMContextImpl::~LLVMContextImpl() {
|
|||||||
for (auto &Pair : ValuesAsMetadata)
|
for (auto &Pair : ValuesAsMetadata)
|
||||||
delete Pair.second;
|
delete Pair.second;
|
||||||
|
|
||||||
// Destroy MDNodes. ~MDNode can move and remove nodes between the MDTuples
|
// Destroy MDNodes.
|
||||||
// and the DistinctMDNodes sets, so copy the values out first.
|
for (auto *I : DistinctMDNodes)
|
||||||
SmallVector<UniquableMDNode *, 8> Uniquables;
|
|
||||||
Uniquables.reserve(MDTuples.size() + DistinctMDNodes.size());
|
|
||||||
Uniquables.append(MDTuples.begin(), MDTuples.end());
|
|
||||||
Uniquables.append(DistinctMDNodes.begin(), DistinctMDNodes.end());
|
|
||||||
for (UniquableMDNode *I : Uniquables)
|
|
||||||
I->dropAllReferences();
|
I->dropAllReferences();
|
||||||
for (UniquableMDNode *I : Uniquables)
|
for (auto *I : MDTuples)
|
||||||
|
I->dropAllReferences();
|
||||||
|
|
||||||
|
for (UniquableMDNode *I : DistinctMDNodes)
|
||||||
delete cast<MDTuple>(I);
|
delete cast<MDTuple>(I);
|
||||||
assert(MDTuples.empty() && DistinctMDNodes.empty() &&
|
for (MDTuple *I : MDTuples)
|
||||||
"Destroying all MDNodes didn't empty the Context's sets.");
|
delete I;
|
||||||
|
|
||||||
// Destroy MDStrings.
|
// Destroy MDStrings.
|
||||||
MDStringCache.clear();
|
MDStringCache.clear();
|
||||||
|
@ -427,13 +427,6 @@ UniquableMDNode::UniquableMDNode(LLVMContext &C, unsigned ID,
|
|||||||
SubclassData32 = NumUnresolved;
|
SubclassData32 = NumUnresolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniquableMDNode::~UniquableMDNode() {
|
|
||||||
if (isStoredDistinctInContext())
|
|
||||||
getContext().pImpl->DistinctMDNodes.erase(this);
|
|
||||||
|
|
||||||
dropAllReferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UniquableMDNode::resolve() {
|
void UniquableMDNode::resolve() {
|
||||||
assert(!isResolved() && "Expected this to be unresolved");
|
assert(!isResolved() && "Expected this to be unresolved");
|
||||||
|
|
||||||
@ -481,11 +474,6 @@ void UniquableMDNode::resolveCycles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MDTuple::~MDTuple() {
|
|
||||||
if (!isStoredDistinctInContext())
|
|
||||||
getContext().pImpl->MDTuples.erase(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MDTuple::recalculateHash() {
|
void MDTuple::recalculateHash() {
|
||||||
setHash(hash_combine_range(op_begin(), op_end()));
|
setHash(hash_combine_range(op_begin(), op_end()));
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user