[ScopInfo] Introduce ScopStmt::contains(BB*). NFC.

Provide an common way for testing if a statement contains something
for region and block statements. First user is
RegionGenerator::addOperandToPHI.

Suggested-by: Tobias Grosser <tobias@grosser.es>
llvm-svn: 298617
This commit is contained in:
Michael Kruse 2017-03-23 16:12:21 +00:00
parent 1c048ab6ba
commit c3e9c1442d
2 changed files with 11 additions and 4 deletions

View File

@ -1324,6 +1324,15 @@ public:
return getRegion()->contains(L);
}
/// Return whether this statement contains @p BB.
bool contains(BasicBlock *BB) const {
if (isCopyStmt())
return false;
if (isBlockStmt())
return BB == getBasicBlock();
return getRegion()->contains(BB);
}
/// Return the closest innermost loop that contains this statement, but is not
/// contained in it.
///

View File

@ -1411,13 +1411,11 @@ void RegionGenerator::generateScalarStores(
void RegionGenerator::addOperandToPHI(ScopStmt &Stmt, PHINode *PHI,
PHINode *PHICopy, BasicBlock *IncomingBB,
LoopToScevMapT &LTS) {
Region *StmtR = Stmt.getRegion();
// If the incoming block was not yet copied mark this PHI as incomplete.
// Once the block will be copied the incoming value will be added.
BasicBlock *BBCopy = BlockMap[IncomingBB];
if (!BBCopy) {
assert(StmtR->contains(IncomingBB) &&
assert(Stmt.contains(IncomingBB) &&
"Bad incoming block for PHI in non-affine region");
IncompletePHINodeMap[IncomingBB].push_back(std::make_pair(PHI, PHICopy));
return;
@ -1428,7 +1426,7 @@ void RegionGenerator::addOperandToPHI(ScopStmt &Stmt, PHINode *PHI,
Value *OpCopy = nullptr;
if (StmtR->contains(IncomingBB)) {
if (Stmt.contains(IncomingBB)) {
Value *Op = PHI->getIncomingValueForBlock(IncomingBB);
// If the current insert block is different from the PHIs incoming block