diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-12 20:09:34 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-12 20:09:34 +0000 |
commit | 118632dbf6851afc878098903a5baf7c8851d3c2 (patch) | |
tree | 2ac4f36d54bae0ee66fd8be3a0978b37840dfc8c /llvm/lib/IR/LLVMContextImpl.cpp | |
parent | 30045e6148d7ad1a209160f1880a9d5a4d5ba26a (diff) | |
download | llvm-118632dbf6851afc878098903a5baf7c8851d3c2.zip llvm-118632dbf6851afc878098903a5baf7c8851d3c2.tar.gz llvm-118632dbf6851afc878098903a5baf7c8851d3c2.tar.bz2 |
IR: Split GenericMDNode into MDTuple and UniquableMDNode
Split `GenericMDNode` into two classes (with more descriptive names).
- `UniquableMDNode` will be a common subclass for `MDNode`s that are
sometimes uniqued like constants, and sometimes 'distinct'.
This class gets the (short-lived) RAUW support and related API.
- `MDTuple` is the basic tuple that has always been returned by
`MDNode::get()`. This is as opposed to more specific nodes to be
added soon, which have additional fields, custom assembly syntax,
and extra semantics.
This class gets the hash-related logic, since other sublcasses of
`UniquableMDNode` may need to hash based on other fields.
To keep this diff from getting too big, I've added casts to `MDTuple`
that won't really scale as new subclasses of `UniquableMDNode` are
added, but I'll clean those up incrementally.
(No functionality change intended.)
llvm-svn: 225682
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index 7c34f09..a9268b4 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -135,17 +135,17 @@ LLVMContextImpl::~LLVMContextImpl() { for (auto &Pair : ValuesAsMetadata) delete Pair.second; - // Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet - // and the NonUniquedMDNodes sets, so copy the values out first. - SmallVector<GenericMDNode *, 8> MDNodes; - MDNodes.reserve(MDNodeSet.size() + NonUniquedMDNodes.size()); - MDNodes.append(MDNodeSet.begin(), MDNodeSet.end()); - MDNodes.append(NonUniquedMDNodes.begin(), NonUniquedMDNodes.end()); - for (GenericMDNode *I : MDNodes) + // 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) I->dropAllReferences(); - for (GenericMDNode *I : MDNodes) - delete I; - assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() && + for (UniquableMDNode *I : Uniquables) + delete cast<MDTuple>(I); + assert(MDTuples.empty() && DistinctMDNodes.empty() && "Destroying all MDNodes didn't empty the Context's sets."); // Destroy MDStrings. |