summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/include/polly/ScopInfo.h2
-rw-r--r--polly/lib/Analysis/DependenceInfo.cpp14
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp41
-rw-r--r--polly/lib/CodeGen/IRBuilder.cpp2
-rw-r--r--polly/lib/CodeGen/Utils.cpp2
-rw-r--r--polly/lib/Exchange/JSONExporter.cpp22
-rw-r--r--polly/lib/Transform/ScheduleOptimizer.cpp2
7 files changed, 38 insertions, 47 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h
index 679e9287868..de8cc8f841c 100644
--- a/polly/include/polly/ScopInfo.h
+++ b/polly/include/polly/ScopInfo.h
@@ -766,7 +766,7 @@ private:
/// Max loop depth.
unsigned MaxLoopDepth;
- typedef std::vector<ScopStmt *> StmtSet;
+ typedef std::vector<std::unique_ptr<ScopStmt>> StmtSet;
/// The statements in this Scop.
StmtSet Stmts;
diff --git a/polly/lib/Analysis/DependenceInfo.cpp b/polly/lib/Analysis/DependenceInfo.cpp
index a56dc8a5611..f0027cbd79a 100644
--- a/polly/lib/Analysis/DependenceInfo.cpp
+++ b/polly/lib/Analysis/DependenceInfo.cpp
@@ -79,12 +79,12 @@ static void collectInfo(Scop &S, isl_union_map **Read, isl_union_map **Write,
*StmtSchedule = isl_union_map_empty(Space);
SmallPtrSet<const Value *, 8> ReductionBaseValues;
- for (ScopStmt *Stmt : S)
+ for (auto &Stmt : S)
for (MemoryAccess *MA : *Stmt)
if (MA->isReductionLike())
ReductionBaseValues.insert(MA->getBaseAddr());
- for (ScopStmt *Stmt : S) {
+ for (auto &Stmt : S) {
for (MemoryAccess *MA : *Stmt) {
isl_set *domcp = Stmt->getDomain();
isl_map *accdom = MA->getAccessRelation();
@@ -361,7 +361,7 @@ void Dependences::calculateDependences(Scop &S) {
// Step 1)
RED = isl_union_map_empty(isl_union_map_get_space(RAW));
- for (ScopStmt *Stmt : S) {
+ for (auto &Stmt : S) {
for (MemoryAccess *MA : *Stmt) {
if (!MA->isReductionLike())
continue;
@@ -404,7 +404,7 @@ void Dependences::calculateDependences(Scop &S) {
// We then move this portion of reduction dependences back to the statement ->
// statement space and add a mapping from the memory access to these
// dependences.
- for (ScopStmt *Stmt : S) {
+ for (auto &Stmt : S) {
for (MemoryAccess *MA : *Stmt) {
if (!MA->isReductionLike())
continue;
@@ -476,13 +476,13 @@ bool Dependences::isValidSchedule(Scop &S,
isl_space *ScheduleSpace = nullptr;
- for (ScopStmt *Stmt : S) {
+ for (auto &Stmt : S) {
isl_map *StmtScat;
- if (NewSchedule->find(Stmt) == NewSchedule->end())
+ if (NewSchedule->find(&*Stmt) == NewSchedule->end())
StmtScat = Stmt->getSchedule();
else
- StmtScat = isl_map_copy((*NewSchedule)[Stmt]);
+ StmtScat = isl_map_copy((*NewSchedule)[&*Stmt]);
if (!ScheduleSpace)
ScheduleSpace = isl_space_range(isl_map_get_space(StmtScat));
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 91283ac849b..97c82c60571 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1349,7 +1349,7 @@ void Scop::realignParams() {
// Align the parameters of all data structures to the model.
Context = isl_set_align_params(Context, Space);
- for (ScopStmt *Stmt : *this)
+ for (auto &Stmt : *this)
Stmt->realignParams();
}
@@ -1476,7 +1476,7 @@ bool Scop::buildAliasGroups(AliasAnalysis &AA) {
DenseMap<Value *, MemoryAccess *> PtrToAcc;
DenseSet<Value *> HasWriteAccess;
- for (ScopStmt *Stmt : *this) {
+ for (auto &Stmt : *this) {
// Skip statements with an empty domain as they will never be executed.
isl_set *StmtDomain = Stmt->getDomain();
@@ -1666,7 +1666,7 @@ void Scop::dropConstantScheduleDims() {
isl_val_free(FixedVal);
}
- for (auto *S : *this) {
+ for (auto &S : *this) {
isl_map *Schedule = S->getSchedule();
Schedule = isl_map_apply_range(Schedule, isl_map_copy(DropDimMap));
S->setSchedule(Schedule);
@@ -1704,10 +1704,6 @@ Scop::~Scop() {
isl_set_free(Context);
isl_set_free(AssumedContext);
- // Free the statements;
- for (ScopStmt *Stmt : *this)
- delete Stmt;
-
// Free the ScopArrayInfo objects.
for (auto &ScopArrayInfoPair : arrays())
delete ScopArrayInfoPair.second;
@@ -1817,7 +1813,7 @@ void Scop::printAliasAssumptions(raw_ostream &OS) const {
void Scop::printStatements(raw_ostream &OS) const {
OS << "Statements {\n";
- for (ScopStmt *Stmt : *this)
+ for (auto &Stmt : *this)
OS.indent(4) << *Stmt;
OS.indent(4) << "}\n";
@@ -1850,7 +1846,7 @@ isl_ctx *Scop::getIslCtx() const { return IslCtx; }
__isl_give isl_union_set *Scop::getDomains() {
isl_union_set *Domain = isl_union_set_empty(getParamSpace());
- for (ScopStmt *Stmt : *this)
+ for (auto &Stmt : *this)
Domain = isl_union_set_add_set(Domain, Stmt->getDomain());
return Domain;
@@ -1859,7 +1855,7 @@ __isl_give isl_union_set *Scop::getDomains() {
__isl_give isl_union_map *Scop::getMustWrites() {
isl_union_map *Write = isl_union_map_empty(this->getParamSpace());
- for (ScopStmt *Stmt : *this) {
+ for (auto &Stmt : *this) {
for (MemoryAccess *MA : *Stmt) {
if (!MA->isMustWrite())
continue;
@@ -1876,7 +1872,7 @@ __isl_give isl_union_map *Scop::getMustWrites() {
__isl_give isl_union_map *Scop::getMayWrites() {
isl_union_map *Write = isl_union_map_empty(this->getParamSpace());
- for (ScopStmt *Stmt : *this) {
+ for (auto &Stmt : *this) {
for (MemoryAccess *MA : *Stmt) {
if (!MA->isMayWrite())
continue;
@@ -1893,7 +1889,7 @@ __isl_give isl_union_map *Scop::getMayWrites() {
__isl_give isl_union_map *Scop::getWrites() {
isl_union_map *Write = isl_union_map_empty(this->getParamSpace());
- for (ScopStmt *Stmt : *this) {
+ for (auto &Stmt : *this) {
for (MemoryAccess *MA : *Stmt) {
if (!MA->isWrite())
continue;
@@ -1910,7 +1906,7 @@ __isl_give isl_union_map *Scop::getWrites() {
__isl_give isl_union_map *Scop::getReads() {
isl_union_map *Read = isl_union_map_empty(getParamSpace());
- for (ScopStmt *Stmt : *this) {
+ for (auto &Stmt : *this) {
for (MemoryAccess *MA : *Stmt) {
if (!MA->isRead())
continue;
@@ -1928,7 +1924,7 @@ __isl_give isl_union_map *Scop::getReads() {
__isl_give isl_union_map *Scop::getSchedule() {
isl_union_map *Schedule = isl_union_map_empty(getParamSpace());
- for (ScopStmt *Stmt : *this)
+ for (auto &Stmt : *this)
Schedule = isl_union_map_add_map(Schedule, Stmt->getSchedule());
return isl_union_map_coalesce(Schedule);
@@ -1936,7 +1932,7 @@ __isl_give isl_union_map *Scop::getSchedule() {
bool Scop::restrictDomains(__isl_take isl_union_set *Domain) {
bool Changed = false;
- for (ScopStmt *Stmt : *this) {
+ for (auto &Stmt : *this) {
isl_union_set *StmtDomain = isl_union_set_from_set(Stmt->getDomain());
isl_union_set *NewStmtDomain = isl_union_set_intersect(
isl_union_set_copy(StmtDomain), isl_union_set_copy(Domain));
@@ -1975,22 +1971,23 @@ void Scop::addScopStmt(BasicBlock *BB, Region *R, TempScop &tempScop,
const Region &CurRegion,
SmallVectorImpl<Loop *> &NestLoops,
SmallVectorImpl<unsigned> &ScheduleVec) {
- ScopStmt *Stmt;
+ std::unique_ptr<ScopStmt> Stmt;
if (BB) {
- Stmt =
- new ScopStmt(*this, tempScop, CurRegion, *BB, NestLoops, ScheduleVec);
- StmtMap[BB] = Stmt;
+ Stmt = std::unique_ptr<ScopStmt>(
+ new ScopStmt(*this, tempScop, CurRegion, *BB, NestLoops, ScheduleVec));
+ StmtMap[BB] = &*Stmt;
} else {
assert(R && "Either a basic block or a region is needed to "
"create a new SCoP stmt.");
- Stmt = new ScopStmt(*this, tempScop, CurRegion, *R, NestLoops, ScheduleVec);
+ Stmt = std::unique_ptr<ScopStmt>(
+ new ScopStmt(*this, tempScop, CurRegion, *R, NestLoops, ScheduleVec));
for (BasicBlock *BB : R->blocks())
- StmtMap[BB] = Stmt;
+ StmtMap[BB] = &*Stmt;
}
// Insert all statements into the statement map and the statement vector.
- Stmts.push_back(Stmt);
+ Stmts.push_back(std::move(Stmt));
// Increasing the Schedule function is OK for the moment, because
// we are using a depth first iterator and the program is well structured.
diff --git a/polly/lib/CodeGen/IRBuilder.cpp b/polly/lib/CodeGen/IRBuilder.cpp
index 53eafb86a1e..ff1ba1bffba 100644
--- a/polly/lib/CodeGen/IRBuilder.cpp
+++ b/polly/lib/CodeGen/IRBuilder.cpp
@@ -59,7 +59,7 @@ void ScopAnnotator::buildAliasScopes(Scop &S) {
OtherAliasScopeListMap.clear();
SetVector<Value *> BasePtrs;
- for (ScopStmt *Stmt : S)
+ for (auto &Stmt : S)
for (MemoryAccess *MA : *Stmt)
BasePtrs.insert(MA->getBaseAddr());
diff --git a/polly/lib/CodeGen/Utils.cpp b/polly/lib/CodeGen/Utils.cpp
index f2ddfd56e7d..fa9a2095e88 100644
--- a/polly/lib/CodeGen/Utils.cpp
+++ b/polly/lib/CodeGen/Utils.cpp
@@ -37,7 +37,7 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) {
std::string OldName = OldBlock->getName();
// Update ScopInfo.
- for (ScopStmt *Stmt : S)
+ for (auto &Stmt : S)
if (Stmt->getBasicBlock() == OldBlock) {
Stmt->setBasicBlock(NewBlock);
break;
diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp
index 6b12667f244..4415bbef0b5 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -102,9 +102,7 @@ Json::Value JSONExporter::getJSON(Scop &S) const {
root["location"] = Location;
root["statements"];
- for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
- ScopStmt *Stmt = *SI;
-
+ for (auto &Stmt : S) {
Json::Value statement;
statement["name"] = Stmt->getBaseName();
@@ -234,10 +232,10 @@ bool JSONImporter::runOnScop(Scop &S) {
int index = 0;
- for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
+ for (auto &Stmt : S) {
Json::Value schedule = jscop["statements"][index]["schedule"];
isl_map *m = isl_map_read_from_str(S.getIslCtx(), schedule.asCString());
- isl_space *Space = (*SI)->getDomainSpace();
+ isl_space *Space = Stmt->getDomainSpace();
// Copy the old tuple id. This is necessary to retain the user pointer,
// that stores the reference to the ScopStmt this schedule belongs to.
@@ -248,7 +246,7 @@ bool JSONImporter::runOnScop(Scop &S) {
m = isl_map_set_dim_id(m, isl_dim_param, i, id);
}
isl_space_free(Space);
- NewSchedule[*SI] = m;
+ NewSchedule[&*Stmt] = m;
index++;
}
@@ -262,17 +260,13 @@ bool JSONImporter::runOnScop(Scop &S) {
return false;
}
- for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
- ScopStmt *Stmt = *SI;
-
- if (NewSchedule.find(Stmt) != NewSchedule.end())
- Stmt->setSchedule(NewSchedule[Stmt]);
+ for (auto &Stmt : S) {
+ if (NewSchedule.find(&*Stmt) != NewSchedule.end())
+ Stmt->setSchedule(NewSchedule[&*Stmt]);
}
int statementIdx = 0;
- for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) {
- ScopStmt *Stmt = *SI;
-
+ for (auto &Stmt : S) {
int memoryAccessIdx = 0;
for (MemoryAccess *MA : *Stmt) {
Json::Value accesses = jscop["statements"][statementIdx]["accesses"]
diff --git a/polly/lib/Transform/ScheduleOptimizer.cpp b/polly/lib/Transform/ScheduleOptimizer.cpp
index 6bf6718b5f7..36cccd8a734 100644
--- a/polly/lib/Transform/ScheduleOptimizer.cpp
+++ b/polly/lib/Transform/ScheduleOptimizer.cpp
@@ -467,7 +467,7 @@ bool IslScheduleOptimizer::runOnScop(Scop &S) {
S.markAsOptimized();
- for (ScopStmt *Stmt : S) {
+ for (auto &Stmt : S) {
isl_map *StmtSchedule;
isl_set *Domain = Stmt->getDomain();
isl_union_map *StmtBand;
OpenPOWER on IntegriCloud