From de835e646dba08da70a9c3affa2f7a83f53e68a7 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 25 Nov 2014 02:26:22 +0000 Subject: [PATCH] Revert "unique_ptrify LLVMContextImpl::CAZConstants" Missed the complexities of how these elements are destroyed. This reverts commit r222714. llvm-svn: 222715 --- lib/IR/Constants.cpp | 8 ++++---- lib/IR/LLVMContextImpl.cpp | 2 +- lib/IR/LLVMContextImpl.h | 5 +---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/IR/Constants.cpp b/lib/IR/Constants.cpp index bc51be6259b..e0cb835c2c6 100644 --- a/lib/IR/Constants.cpp +++ b/lib/IR/Constants.cpp @@ -1330,12 +1330,12 @@ bool ConstantFP::isValueValidForType(Type *Ty, const APFloat& Val) { ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) { assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && "Cannot create an aggregate zero of non-aggregate type!"); - - auto &Entry = Ty->getContext().pImpl->CAZConstants[Ty]; + + ConstantAggregateZero *&Entry = Ty->getContext().pImpl->CAZConstants[Ty]; if (!Entry) - Entry.reset(new ConstantAggregateZero(Ty)); + Entry = new ConstantAggregateZero(Ty); - return Entry.get(); + return Entry; } /// destroyConstant - Remove the constant from the constant table. diff --git a/lib/IR/LLVMContextImpl.cpp b/lib/IR/LLVMContextImpl.cpp index 1335b3d33b8..3fd0bb37a4d 100644 --- a/lib/IR/LLVMContextImpl.cpp +++ b/lib/IR/LLVMContextImpl.cpp @@ -87,7 +87,7 @@ LLVMContextImpl::~LLVMContextImpl() { ArrayConstants.freeConstants(); StructConstants.freeConstants(); VectorConstants.freeConstants(); - CAZConstants.clear(); + DeleteContainerSeconds(CAZConstants); DeleteContainerSeconds(CPNConstants); DeleteContainerSeconds(UVConstants); InlineAsms.freeConstants(); diff --git a/lib/IR/LLVMContextImpl.h b/lib/IR/LLVMContextImpl.h index 65d6774e335..7a298cfecf3 100644 --- a/lib/IR/LLVMContextImpl.h +++ b/lib/IR/LLVMContextImpl.h @@ -299,10 +299,7 @@ public: // on Context destruction. SmallPtrSet NonUniquedMDNodes; - // Value is indirected through pointer to keep pointer validity over mutations - // of this map. Replace if/when we have an efficient map that guarantees - // pointer validity over mutations. - DenseMap> CAZConstants; + DenseMap CAZConstants; typedef ConstantUniqueMap ArrayConstantsTy; ArrayConstantsTy ArrayConstants;