diff options
author | Michael Kruse <llvm@meinersbur.de> | 2018-04-09 23:13:05 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2018-04-09 23:13:05 +0000 |
commit | 192e7f72cae7f41b90f260f9fda334cd777e6ad6 (patch) | |
tree | 25b887724561f7e7f4ef488d08fe6ecd1be5956c /polly/lib/Analysis/ScopInfo.cpp | |
parent | 7de61668aedf4ac986a303a34aba98a452c6abef (diff) | |
download | bcm5719-llvm-192e7f72cae7f41b90f260f9fda334cd777e6ad6.tar.gz bcm5719-llvm-192e7f72cae7f41b90f260f9fda334cd777e6ad6.zip |
[ScopInfo] Completely remove MemoryAccesses when their parent statement is removed.
Removing a statement left its MemoryAccesses in some lists and maps of
the SCoP. Which lists depends on at which phase of the SCoP
construction the statement is deleted. Follow-up passes could still see
the already deleted MemoryAccesses by iterating through these
lists/maps, resulting in an access violation.
When removing a ScopStmt, also remove all its MemoryAccesses by using
the same mechnism that removes a MemoryAccess.
llvm-svn: 329640
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) { |