diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-11-25 02:13:54 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-11-25 02:13:54 +0000 |
| commit | 899b85a556e5493beea0ef0d914d5a454e6b1a81 (patch) | |
| tree | d176ca66699720a20df571dd3a1cc2639b9dab8e /llvm/lib | |
| parent | 59016765817633ba125e2c014fd4c6c5de461fa9 (diff) | |
| download | bcm5719-llvm-899b85a556e5493beea0ef0d914d5a454e6b1a81.tar.gz bcm5719-llvm-899b85a556e5493beea0ef0d914d5a454e6b1a81.zip | |
unique_ptrify LLVMContextImpl::CAZConstants
llvm-svn: 222714
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/Constants.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/IR/LLVMContextImpl.h | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index e0cb835c2c6..bc51be6259b 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/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!"); - - ConstantAggregateZero *&Entry = Ty->getContext().pImpl->CAZConstants[Ty]; + + auto &Entry = Ty->getContext().pImpl->CAZConstants[Ty]; if (!Entry) - Entry = new ConstantAggregateZero(Ty); + Entry.reset(new ConstantAggregateZero(Ty)); - return Entry; + return Entry.get(); } /// destroyConstant - Remove the constant from the constant table. diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index 3fd0bb37a4d..1335b3d33b8 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -87,7 +87,7 @@ LLVMContextImpl::~LLVMContextImpl() { ArrayConstants.freeConstants(); StructConstants.freeConstants(); VectorConstants.freeConstants(); - DeleteContainerSeconds(CAZConstants); + CAZConstants.clear(); DeleteContainerSeconds(CPNConstants); DeleteContainerSeconds(UVConstants); InlineAsms.freeConstants(); diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index 7a298cfecf3..65d6774e335 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -299,7 +299,10 @@ public: // on Context destruction. SmallPtrSet<GenericMDNode *, 1> NonUniquedMDNodes; - DenseMap<Type*, ConstantAggregateZero*> CAZConstants; + // 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<Type*, std::unique_ptr<ConstantAggregateZero>> CAZConstants; typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy; ArrayConstantsTy ArrayConstants; |

