llvm.org GIT mirror llvm / d1ec4f0
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 Duncan P. N. Exon Smith 5 years ago
3 changed file(s) with 10 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
721721 /// resolveCycles() is called).
722722 UniquableMDNode(LLVMContext &C, unsigned ID, ArrayRef Vals,
723723 bool AllowRAUW);
724 ~UniquableMDNode();
724 ~UniquableMDNode() {}
725725
726726 void storeDistinctInContext();
727727
766766
767767 MDTuple(LLVMContext &C, ArrayRef Vals, bool AllowRAUW)
768768 : UniquableMDNode(C, MDTupleKind, Vals, AllowRAUW) {}
769 ~MDTuple();
769 ~MDTuple() { dropAllReferences(); }
770770
771771 void setHash(unsigned Hash) { MDNodeSubclassData = Hash; }
772772 void recalculateHash();
134134 for (auto &Pair : ValuesAsMetadata)
135135 delete Pair.second;
136136
137 // Destroy MDNodes. ~MDNode can move and remove nodes between the MDTuples
138 // and the DistinctMDNodes sets, so copy the values out first.
139 SmallVector Uniquables;
140 Uniquables.reserve(MDTuples.size() + DistinctMDNodes.size());
141 Uniquables.append(MDTuples.begin(), MDTuples.end());
142 Uniquables.append(DistinctMDNodes.begin(), DistinctMDNodes.end());
143 for (UniquableMDNode *I : Uniquables)
137 // Destroy MDNodes.
138 for (auto *I : DistinctMDNodes)
144139 I->dropAllReferences();
145 for (UniquableMDNode *I : Uniquables)
140 for (auto *I : MDTuples)
141 I->dropAllReferences();
142
143 for (UniquableMDNode *I : DistinctMDNodes)
146144 delete cast(I);
147 assert(MDTuples.empty() && DistinctMDNodes.empty() &&
148 "Destroying all MDNodes didn't empty the Context's sets.");
145 for (MDTuple *I : MDTuples)
146 delete I;
149147
150148 // Destroy MDStrings.
151149 MDStringCache.clear();
426426 SubclassData32 = NumUnresolved;
427427 }
428428
429 UniquableMDNode::~UniquableMDNode() {
430 if (isStoredDistinctInContext())
431 getContext().pImpl->DistinctMDNodes.erase(this);
432
433 dropAllReferences();
434 }
435
436429 void UniquableMDNode::resolve() {
437430 assert(!isResolved() && "Expected this to be unresolved");
438431
478471 if (!N->isResolved())
479472 N->resolveCycles();
480473 }
481 }
482
483 MDTuple::~MDTuple() {
484 if (!isStoredDistinctInContext())
485 getContext().pImpl->MDTuples.erase(this);
486474 }
487475
488476 void MDTuple::recalculateHash() {