diff options
-rw-r--r-- | polly/include/polly/ScopInfo.h | 3 | ||||
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 66889ff236e..fbaa5a83b59 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1253,6 +1253,9 @@ private: llvm::SmallVectorImpl<MemoryAccess *> &Loads); //@} + /// Remove @p MA from dictionaries pointing to them. + void removeAccessData(MemoryAccess *MA); + public: ~ScopStmt(); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index bfc27a62c15..a5406100bf0 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -1858,6 +1858,24 @@ void ScopStmt::print(raw_ostream &OS) const { void ScopStmt::dump() const { print(dbgs()); } +void ScopStmt::removeAccessData(MemoryAccess *MA) { + if (MA->isRead() && MA->isOriginalValueKind()) { + bool Found = ValueReads.erase(MA->getAccessValue()); + (void)Found; + assert(Found && "Expected access data not found"); + } + if (MA->isWrite() && MA->isOriginalValueKind()) { + bool Found = ValueWrites.erase(cast<Instruction>(MA->getAccessValue())); + (void)Found; + assert(Found && "Expected access data not found"); + } + if (MA->isWrite() && MA->isOriginalAnyPHIKind()) { + bool Found = PHIWrites.erase(cast<PHINode>(MA->getAccessInstruction())); + (void)Found; + assert(Found && "Expected access data not found"); + } +} + void ScopStmt::removeMemoryAccess(MemoryAccess *MA) { // Remove the memory accesses from this statement together with all scalar // accesses that were caused by it. MemoryKind::Value READs have no access @@ -1868,6 +1886,10 @@ void ScopStmt::removeMemoryAccess(MemoryAccess *MA) { auto Predicate = [&](MemoryAccess *Acc) { return Acc->getAccessInstruction() == MA->getAccessInstruction(); }; + for (auto *MA : MemAccs) { + if (Predicate(MA)) + removeAccessData(MA); + } MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate), MemAccs.end()); InstructionToAccess.erase(MA->getAccessInstruction()); @@ -1878,6 +1900,8 @@ void ScopStmt::removeSingleMemoryAccess(MemoryAccess *MA) { assert(MAIt != MemAccs.end()); MemAccs.erase(MAIt); + removeAccessData(MA); + auto It = InstructionToAccess.find(MA->getAccessInstruction()); if (It != InstructionToAccess.end()) { It->second.remove(MA); |