From a8fb73fc0be2dcd6609163e1d8e61df861f43f06 Mon Sep 17 00:00:00 2001 From: Hongbin Zheng Date: Mon, 21 Nov 2016 20:09:40 +0000 Subject: [PATCH] Split ScopInfo::addScopStmt into two versions. NFC One for adding statement for region, another one for BB llvm-svn: 287566 --- polly/include/polly/ScopInfo.h | 19 +++++++++++++------ polly/lib/Analysis/ScopBuilder.cpp | 4 ++-- polly/lib/Analysis/ScopInfo.cpp | 23 ++++++++++++----------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 4e92cbf..0a512ac 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1858,14 +1858,21 @@ private: /// @return The representing SCEV for invariant loads or @p S if none. const SCEV *getRepresentingInvariantLoadSCEV(const SCEV *S); - /// Create a new SCoP statement for either @p BB or @p R. + /// Create a new SCoP statement for either @p BB. /// - /// Either @p BB or @p R should be non-null. A new statement for the non-null - /// argument will be created and added to the statement vector and map. + /// A new statement for @p BB will be created and added to the statement vector + /// and map. /// - /// @param BB The basic block we build the statement for (or null) - /// @param R The region we build the statement for (or null). - void addScopStmt(BasicBlock *BB, Region *R); + /// @param BB The basic block we build the statement for. + void addScopStmt(BasicBlock *BB); + + /// Create a new SCoP statement for either @p R. + /// + /// A new statement for @p R will be created and added to the statement vector + /// and map. + /// + /// @param R The region we build the statement for. + void addScopStmt(Region *R); /// @param Update access dimensionalities. /// diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp index 4e76d5d..7c45aa9 100644 --- a/polly/lib/Analysis/ScopBuilder.cpp +++ b/polly/lib/Analysis/ScopBuilder.cpp @@ -430,7 +430,7 @@ void ScopBuilder::buildAccessFunctions(Region &SR) { void ScopBuilder::buildStmts(Region &SR) { if (scop->isNonAffineSubRegion(&SR)) { - scop->addScopStmt(nullptr, &SR); + scop->addScopStmt(&SR); return; } @@ -438,7 +438,7 @@ void ScopBuilder::buildStmts(Region &SR) { if (I->isSubRegion()) buildStmts(*I->getNodeAs()); else - scop->addScopStmt(I->getNodeAs(), nullptr); + scop->addScopStmt(I->getNodeAs()); } void ScopBuilder::buildAccessFunctions(BasicBlock &BB, diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index fb21ba4..38daef3 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -4206,18 +4206,19 @@ mapToDimension(__isl_take isl_union_set *USet, int N) { return isl_multi_union_pw_aff_from_union_pw_multi_aff(Data.Res); } -void Scop::addScopStmt(BasicBlock *BB, Region *R) { - if (BB) { - Stmts.emplace_back(*this, *BB); - auto *Stmt = &Stmts.back(); +void Scop::addScopStmt(BasicBlock *BB) { + assert(BB && "Unexpected nullptr!"); + Stmts.emplace_back(*this, *BB); + auto *Stmt = &Stmts.back(); + StmtMap[BB] = Stmt; +} + +void Scop::addScopStmt(Region *R) { + assert(R && "Unexpected nullptr!"); + Stmts.emplace_back(*this, *R); + auto *Stmt = &Stmts.back(); + for (BasicBlock *BB : R->blocks()) StmtMap[BB] = Stmt; - } else { - assert(R && "Either basic block or a region expected."); - Stmts.emplace_back(*this, *R); - auto *Stmt = &Stmts.back(); - for (BasicBlock *BB : R->blocks()) - StmtMap[BB] = Stmt; - } } ScopStmt *Scop::addScopStmt(__isl_take isl_map *SourceRel, -- 2.7.4