From e60eca7316fffeed4f42dc1dcd5900679f0be647 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Thu, 11 May 2017 22:56:12 +0000 Subject: [ScopInfo] Keep scalar acceess dictionaries up-to-data. NFC. When removing a MemoryAccess, also remove it from maps pointing to it. This was already done for InstructionToAccess, but not yet for ValueReads, ValueWrites and PHIWrites as those were only used during the ScopBuilder phase. Keeping them updated allows us to use them later as well. llvm-svn: 302836 --- polly/include/polly/ScopInfo.h | 3 +++ polly/lib/Analysis/ScopInfo.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) 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 &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(MA->getAccessValue())); + (void)Found; + assert(Found && "Expected access data not found"); + } + if (MA->isWrite() && MA->isOriginalAnyPHIKind()) { + bool Found = PHIWrites.erase(cast(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); -- cgit v1.2.3