diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-12 20:50:25 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-12 20:50:25 +0000 |
commit | 6b1f4659f98d3471dd8e821b5e60ca9abdb78421 (patch) | |
tree | 298f175d833994234b5b48ca5a9cd36531331609 /llvm/lib/IR/LLVMContextImpl.cpp | |
parent | a2dece27e4c9e82f87f7abec5ce805632e12863c (diff) | |
download | bcm5719-llvm-6b1f4659f98d3471dd8e821b5e60ca9abdb78421.tar.gz bcm5719-llvm-6b1f4659f98d3471dd8e821b5e60ca9abdb78421.zip |
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).
llvm-svn: 225696
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index a9268b46488..c78b76021da 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -135,18 +135,16 @@ LLVMContextImpl::~LLVMContextImpl() { for (auto &Pair : ValuesAsMetadata) delete Pair.second; - // Destroy MDNodes. ~MDNode can move and remove nodes between the MDTuples - // and the DistinctMDNodes sets, so copy the values out first. - 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) + // Destroy MDNodes. + for (auto *I : DistinctMDNodes) I->dropAllReferences(); - for (UniquableMDNode *I : Uniquables) + for (auto *I : MDTuples) + I->dropAllReferences(); + + for (UniquableMDNode *I : DistinctMDNodes) delete cast<MDTuple>(I); - assert(MDTuples.empty() && DistinctMDNodes.empty() && - "Destroying all MDNodes didn't empty the Context's sets."); + for (MDTuple *I : MDTuples) + delete I; // Destroy MDStrings. MDStringCache.clear(); |