X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FLLVMContextImpl.cpp;h=6279bb823dbf23b1e5823713296e992848c319b3;hb=e38ec24758bf88f68159ced232c371ffe031de00;hp=b0dd680926d75517d80802ad63e0c3949559e299;hpb=95889fa9c31779c9ef3e71d633b8d9146648bc97;p=oota-llvm.git diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp index b0dd680926d..6279bb823db 100644 --- a/lib/VMCore/LLVMContextImpl.cpp +++ b/lib/VMCore/LLVMContextImpl.cpp @@ -48,6 +48,16 @@ struct DropReferences { P.second->dropAllReferences(); } }; + +// Temporary - drops pair.first instead of second. +struct DropFirst { + // Takes the value_type of a ConstantUniqueMap's internal map, whose 'second' + // is a Constant*. + template + void operator()(const PairT &P) { + P.first->dropAllReferences(); + } +}; } LLVMContextImpl::~LLVMContextImpl() { @@ -58,25 +68,32 @@ LLVMContextImpl::~LLVMContextImpl() { std::vector Modules(OwnedModules.begin(), OwnedModules.end()); DeleteContainerPointers(Modules); + // Free the constants. This is important to do here to ensure that they are + // freed before the LeakDetector is torn down. std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(), DropReferences()); std::for_each(ArrayConstants.map_begin(), ArrayConstants.map_end(), - DropReferences()); + DropFirst()); std::for_each(StructConstants.map_begin(), StructConstants.map_end(), - DropReferences()); + DropFirst()); std::for_each(VectorConstants.map_begin(), VectorConstants.map_end(), - DropReferences()); + DropFirst()); ExprConstants.freeConstants(); ArrayConstants.freeConstants(); StructConstants.freeConstants(); VectorConstants.freeConstants(); - AggZeroConstants.freeConstants(); - NullPtrConstants.freeConstants(); - UndefValueConstants.freeConstants(); + DeleteContainerSeconds(CAZConstants); + DeleteContainerSeconds(CPNConstants); + DeleteContainerSeconds(UVConstants); InlineAsms.freeConstants(); DeleteContainerSeconds(IntConstants); DeleteContainerSeconds(FPConstants); + for (StringMap::iterator I = CDSConstants.begin(), + E = CDSConstants.end(); I != E; ++I) + delete I->second; + CDSConstants.clear(); + // Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet // and the NonUniquedMDNodes sets, so copy the values out first. SmallVector MDNodes;