From 286d9e4b9d5a48e60c3f25a85578641e72b26ead Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 10 Aug 2009 22:59:46 +0000 Subject: [PATCH] Remove MDNode from ValueMap when MDNode is destroyed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78612 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/LLVMContextImpl.h | 2 +- lib/VMCore/Metadata.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h index fda56083b06..3d1f3b26a5c 100644 --- a/lib/VMCore/LLVMContextImpl.h +++ b/lib/VMCore/LLVMContextImpl.h @@ -105,7 +105,7 @@ struct LLVMContextImpl { ValueMap AggZeroConstants; - ValueMap, Type, MDNode> MDNodes; + ValueMap, Type, MDNode, true /*largekey*/> MDNodes; typedef ValueMap, ArrayType, ConstantArray, true /*largekey*/> ArrayConstantsTy; diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 1680572ab93..3a61d0eefb7 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -92,8 +92,17 @@ void MDNode::dropAllReferences() { Node.clear(); } +static std::vector getValType(MDNode *N) { + std::vector Elements; + Elements.reserve(N->getNumElements()); + for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) + Elements.push_back(N->getElement(i)); + return Elements; +} + MDNode::~MDNode() { dropAllReferences(); + getType()->getContext().pImpl->MDNodes.remove(this); } //===----------------------------------------------------------------------===// //NamedMDNode implementation