Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -2625,13 +2625,16 @@ /// none. ScopStmt *getStmtFor(BasicBlock *BB) const; + /// Return the list of ScopStmts that represent the given @p BB. + ArrayRef 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. Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -4982,6 +4982,22 @@ return StmtMapIt->second.front(); } +ArrayRef 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 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());