[polly] r238091 - Use unique_ptr to clarify ownershop of ScopArrayInfoMap
Tobias Grosser
tobias at grosser.es
Fri May 22 22:58:27 PDT 2015
Author: grosser
Date: Sat May 23 00:58:27 2015
New Revision: 238091
URL: http://llvm.org/viewvc/llvm-project?rev=238091&view=rev
Log:
Use unique_ptr to clarify ownershop of ScopArrayInfoMap
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=238091&r1=238090&r2=238091&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Sat May 23 00:58:27 2015
@@ -787,7 +787,8 @@ private:
/// Constraints on parameters.
isl_set *Context;
- typedef MapVector<const Value *, const ScopArrayInfo *> ArrayInfoMapTy;
+ typedef MapVector<const Value *, std::unique_ptr<ScopArrayInfo>>
+ ArrayInfoMapTy;
/// @brief A map to remember ScopArrayInfo objects for all base pointers.
ArrayInfoMapTy ScopArrayInfoMap;
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=238091&r1=238090&r2=238091&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sat May 23 00:58:27 2015
@@ -1704,10 +1704,6 @@ Scop::~Scop() {
isl_set_free(Context);
isl_set_free(AssumedContext);
- // Free the ScopArrayInfo objects.
- for (auto &ScopArrayInfoPair : arrays())
- delete ScopArrayInfoPair.second;
-
// Free the alias groups
for (MinMaxVectorTy *MinMaxAccesses : MinMaxAliasGroups) {
for (MinMaxAccessTy &MMA : *MinMaxAccesses) {
@@ -1721,17 +1717,17 @@ Scop::~Scop() {
const ScopArrayInfo *
Scop::getOrCreateScopArrayInfo(Value *BasePtr, Type *AccessType,
const SmallVector<const SCEV *, 4> &Sizes) {
- const ScopArrayInfo *&SAI = ScopArrayInfoMap[BasePtr];
+ auto &SAI = ScopArrayInfoMap[BasePtr];
if (!SAI)
- SAI = new ScopArrayInfo(BasePtr, AccessType, getIslCtx(), Sizes);
- return SAI;
+ SAI.reset(new ScopArrayInfo(BasePtr, AccessType, getIslCtx(), Sizes));
+ return SAI.get();
}
const ScopArrayInfo *Scop::getScopArrayInfo(Value *BasePtr) {
const SCEV *PtrSCEV = SE->getSCEV(BasePtr);
const SCEVUnknown *PtrBaseSCEV =
cast<SCEVUnknown>(SE->getPointerBase(PtrSCEV));
- const ScopArrayInfo *SAI = ScopArrayInfoMap[PtrBaseSCEV->getValue()];
+ const ScopArrayInfo *SAI = ScopArrayInfoMap[PtrBaseSCEV->getValue()].get();
assert(SAI && "No ScopArrayInfo available for this base pointer");
return SAI;
}
@@ -1822,7 +1818,7 @@ void Scop::printStatements(raw_ostream &
void Scop::printArrayInfo(raw_ostream &OS) const {
OS << "Arrays {\n";
- for (auto Array : arrays())
+ for (auto &Array : arrays())
Array.second->print(OS);
OS.indent(4) << "}\n";
More information about the llvm-commits
mailing list