diff options
| author | Michael Kruse <llvm@meinersbur.de> | 2017-05-11 22:56:12 +0000 |
|---|---|---|
| committer | Michael Kruse <llvm@meinersbur.de> | 2017-05-11 22:56:12 +0000 |
| commit | e60eca7316fffeed4f42dc1dcd5900679f0be647 (patch) | |
| tree | 9742a38a4b7c9378f0bd6c6fcc3b529e9332e22d | |
| parent | 43bbeb4c9f69f652a3219c70b448388b55cfaa89 (diff) | |
| download | bcm5719-llvm-e60eca7316fffeed4f42dc1dcd5900679f0be647.tar.gz bcm5719-llvm-e60eca7316fffeed4f42dc1dcd5900679f0be647.zip | |
[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
| -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); |

