[llvm] r222715 - Revert "unique_ptrify LLVMContextImpl::CAZConstants"

David Blaikie dblaikie at gmail.com
Mon Nov 24 18:26:23 PST 2014


Author: dblaikie
Date: Mon Nov 24 20:26:22 2014
New Revision: 222715

URL: http://llvm.org/viewvc/llvm-project?rev=222715&view=rev
Log:
Revert "unique_ptrify LLVMContextImpl::CAZConstants"

Missed the complexities of how these elements are destroyed.

This reverts commit r222714.

Modified:
    llvm/trunk/lib/IR/Constants.cpp
    llvm/trunk/lib/IR/LLVMContextImpl.cpp
    llvm/trunk/lib/IR/LLVMContextImpl.h

Modified: llvm/trunk/lib/IR/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Constants.cpp?rev=222715&r1=222714&r2=222715&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Constants.cpp (original)
+++ llvm/trunk/lib/IR/Constants.cpp Mon Nov 24 20:26:22 2014
@@ -1330,12 +1330,12 @@ bool ConstantFP::isValueValidForType(Typ
 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.

Modified: llvm/trunk/lib/IR/LLVMContextImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.cpp?rev=222715&r1=222714&r2=222715&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.cpp Mon Nov 24 20:26:22 2014
@@ -87,7 +87,7 @@ LLVMContextImpl::~LLVMContextImpl() {
   ArrayConstants.freeConstants();
   StructConstants.freeConstants();
   VectorConstants.freeConstants();
-  CAZConstants.clear();
+  DeleteContainerSeconds(CAZConstants);
   DeleteContainerSeconds(CPNConstants);
   DeleteContainerSeconds(UVConstants);
   InlineAsms.freeConstants();

Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=222715&r1=222714&r2=222715&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Mon Nov 24 20:26:22 2014
@@ -299,10 +299,7 @@ public:
   // on Context destruction.
   SmallPtrSet<GenericMDNode *, 1> 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<Type*, std::unique_ptr<ConstantAggregateZero>> CAZConstants;
+  DenseMap<Type*, ConstantAggregateZero*> CAZConstants;
 
   typedef ConstantUniqueMap<ConstantArray> ArrayConstantsTy;
   ArrayConstantsTy ArrayConstants;





More information about the llvm-commits mailing list