[polly] r308633 - [ScopInfo] Remove dependency of Scop::getLastStmtFor(BB) on getStmtFor(BB). NFC.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 10:08:50 PDT 2017
Author: meinersbur
Date: Thu Jul 20 10:08:50 2017
New Revision: 308633
URL: http://llvm.org/viewvc/llvm-project?rev=308633&view=rev
Log:
[ScopInfo] Remove dependency of Scop::getLastStmtFor(BB) on getStmtFor(BB). NFC.
We are working towards removing uses of Scop::getStmtFor(BB). In this
patch, we remove dependency of Scop::getLastStmtFor(BB) on
getStmtFor(BB). To do so, we get the list of all statements
corresponding to the BB and then fetch the last one.
Contributed-by: Nandini Singhal <cs15mtech01004 at iith.ac.in>
Differential Revision: https://reviews.llvm.org/D35665
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=308633&r1=308632&r2=308633&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Thu Jul 20 10:08:50 2017
@@ -2667,13 +2667,16 @@ public:
/// none.
ScopStmt *getStmtFor(BasicBlock *BB) const;
+ /// Return the list of ScopStmts that represent the given @p BB.
+ ArrayRef<ScopStmt *> getStmtListFor(BasicBlock *BB) const;
+
/// Return the last statement representing @p BB.
///
/// Of the sequence of statements that represent a @p BB, this is the last one
/// to be executed. It is typically used to determine which instruction to add
/// a MemoryKind::PHI WRITE to. For this purpose, it is not strictly required
/// to be executed last, only that the incoming value is available in it.
- ScopStmt *getLastStmtFor(BasicBlock *BB) const { return getStmtFor(BB); }
+ ScopStmt *getLastStmtFor(BasicBlock *BB) const;
/// Return the ScopStmt that represents the Region @p R, or nullptr if
/// it is not represented by any statement in this Scop.
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=308633&r1=308632&r2=308633&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Jul 20 10:08:50 2017
@@ -4979,6 +4979,22 @@ ScopStmt *Scop::getStmtFor(BasicBlock *B
return StmtMapIt->second.front();
}
+ArrayRef<ScopStmt *> Scop::getStmtListFor(BasicBlock *BB) const {
+ auto StmtMapIt = StmtMap.find(BB);
+ if (StmtMapIt == StmtMap.end())
+ return {};
+ assert(StmtMapIt->second.size() == 1 &&
+ "Each statement corresponds to exactly one BB.");
+ return StmtMapIt->second;
+}
+
+ScopStmt *Scop::getLastStmtFor(BasicBlock *BB) const {
+ ArrayRef<ScopStmt *> StmtList = getStmtListFor(BB);
+ if (StmtList.size() > 0)
+ return StmtList.back();
+ return nullptr;
+}
+
ScopStmt *Scop::getStmtFor(RegionNode *RN) const {
if (RN->isSubRegion())
return getStmtFor(RN->getNodeAs<Region>());
More information about the llvm-commits
mailing list