Revert "unique_ptrify LLVMContextImpl::CAZConstants"

Missed the complexities of how these elements are destroyed.

This reverts commit r222714.

llvm-svn: 222715
This commit is contained in:
David Blaikie 2014-11-25 02:26:22 +00:00
parent 14dc3c5b02
commit de835e646d
3 changed files with 6 additions and 9 deletions

View File

@ -1330,12 +1330,12 @@ bool ConstantFP::isValueValidForType(Type *Ty, const APFloat& Val) {
ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) { ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) {
assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) &&
"Cannot create an aggregate zero of non-aggregate type!"); "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) if (!Entry)
Entry.reset(new ConstantAggregateZero(Ty)); Entry = new ConstantAggregateZero(Ty);
return Entry.get(); return Entry;
} }
/// destroyConstant - Remove the constant from the constant table. /// destroyConstant - Remove the constant from the constant table.

View File

@ -87,7 +87,7 @@ LLVMContextImpl::~LLVMContextImpl() {
ArrayConstants.freeConstants(); ArrayConstants.freeConstants();
StructConstants.freeConstants(); StructConstants.freeConstants();
VectorConstants.freeConstants(); VectorConstants.freeConstants();
CAZConstants.clear(); DeleteContainerSeconds(CAZConstants);
DeleteContainerSeconds(CPNConstants); DeleteContainerSeconds(CPNConstants);
DeleteContainerSeconds(UVConstants); DeleteContainerSeconds(UVConstants);
InlineAsms.freeConstants(); InlineAsms.freeConstants();

View File

@ -299,10 +299,7 @@ public:
// on Context destruction. // on Context destruction.
SmallPtrSet<GenericMDNode *, 1> NonUniquedMDNodes; SmallPtrSet<GenericMDNode *, 1> NonUniquedMDNodes;
// Value is indirected through pointer to keep pointer validity over mutations DenseMap<Type*, ConstantAggregateZero*> CAZConstants;
// 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; typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy;
ArrayConstantsTy ArrayConstants; ArrayConstantsTy ArrayConstants;