diff options
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 81edb824c05..61552929f95 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1819,13 +1819,15 @@ void ScopStmt::removeMemoryAccess(MemoryAccess *MA) { InstructionToAccess.erase(MA->getAccessInstruction()); } -void ScopStmt::removeSingleMemoryAccess(MemoryAccess *MA) { - auto MAIt = std::find(MemAccs.begin(), MemAccs.end(), MA); - assert(MAIt != MemAccs.end()); - MemAccs.erase(MAIt); - - removeAccessData(MA); - Parent.removeAccessData(MA); +void ScopStmt::removeSingleMemoryAccess(MemoryAccess *MA, bool AfterHoisting) { + if (AfterHoisting) { + auto MAIt = std::find(MemAccs.begin(), MemAccs.end(), MA); + assert(MAIt != MemAccs.end()); + MemAccs.erase(MAIt); + + removeAccessData(MA); + Parent.removeAccessData(MA); + } auto It = InstructionToAccess.find(MA->getAccessInstruction()); if (It != InstructionToAccess.end()) { @@ -3553,13 +3555,19 @@ void Scop::removeFromStmtMap(ScopStmt &Stmt) { } } -void Scop::removeStmts(std::function<bool(ScopStmt &)> ShouldDelete) { +void Scop::removeStmts(std::function<bool(ScopStmt &)> ShouldDelete, + bool AfterHoisting) { for (auto StmtIt = Stmts.begin(), StmtEnd = Stmts.end(); StmtIt != StmtEnd;) { if (!ShouldDelete(*StmtIt)) { StmtIt++; continue; } + // Start with removing all of the statement's accesses including erasing it + // from all maps that are pointing to them. + for (auto *MA : *StmtIt) + StmtIt->removeSingleMemoryAccess(MA, AfterHoisting); + removeFromStmtMap(*StmtIt); StmtIt = Stmts.erase(StmtIt); } @@ -3569,7 +3577,7 @@ void Scop::removeStmtNotInDomainMap() { auto ShouldDelete = [this](ScopStmt &Stmt) -> bool { return !this->DomainMap.lookup(Stmt.getEntryBlock()); }; - removeStmts(ShouldDelete); + removeStmts(ShouldDelete, false); } void Scop::simplifySCoP(bool AfterHoisting) { @@ -3592,7 +3600,7 @@ void Scop::simplifySCoP(bool AfterHoisting) { return RemoveStmt; }; - removeStmts(ShouldDelete); + removeStmts(ShouldDelete, AfterHoisting); } InvariantEquivClassTy *Scop::lookupInvariantEquivClass(Value *Val) { |