[PATCH] D35665: [Polly] Remove dependency of `Scop::getLastStmtFor(BB)` on `getStmtFor(BB)`. [NFC].
Nandini Singhal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 01:26:24 PDT 2017
nandini12396 created this revision.
nandini12396 added a project: Polly.
Herald added a reviewer: bollu.
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.
https://reviews.llvm.org/D35665
Files:
include/polly/ScopInfo.h
lib/Analysis/ScopInfo.cpp
Index: lib/Analysis/ScopInfo.cpp
===================================================================
--- lib/Analysis/ScopInfo.cpp
+++ lib/Analysis/ScopInfo.cpp
@@ -4912,6 +4912,21 @@
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 {
+ if (getStmtListFor(BB).size() > 0)
+ return getStmtListFor(BB).back();
+ return nullptr;
+}
+
ScopStmt *Scop::getStmtFor(RegionNode *RN) const {
if (RN->isSubRegion())
return getStmtFor(RN->getNodeAs<Region>());
Index: include/polly/ScopInfo.h
===================================================================
--- include/polly/ScopInfo.h
+++ include/polly/ScopInfo.h
@@ -2610,13 +2610,16 @@
/// 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35665.107460.patch
Type: text/x-patch
Size: 1839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170720/6629b0de/attachment.bin>
More information about the llvm-commits
mailing list