summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2015-11-30 17:20:40 +0000
committerTobias Grosser <tobias@grosser.es>2015-11-30 17:20:40 +0000
commitef9ca5db16970b8cbedae7cc9ef2e34dbe2b28c2 (patch)
tree8e5ef31dc9442aea389619c191f8604068a773a2
parentea03cf2fa108b0e724a2f2f29077700d870f28e2 (diff)
downloadbcm5719-llvm-ef9ca5db16970b8cbedae7cc9ef2e34dbe2b28c2.tar.gz
bcm5719-llvm-ef9ca5db16970b8cbedae7cc9ef2e34dbe2b28c2.zip
ScopInfo: Replace while/iterator construct with std::remove_if
The use of C++'s high-level iterator functionality instead of two while loops and explicit iterator handling improves readability of this code. Proposed-by: Michael Kruse <llvm@meinersbur.de> Differential Revision: http://reviews.llvm.org/D15068 llvm-svn: 254305
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp30
1 files changed, 9 insertions, 21 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 5f902029305..093cfb09af9 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1464,29 +1464,17 @@ void ScopStmt::print(raw_ostream &OS) const {
void ScopStmt::dump() const { print(dbgs()); }
void ScopStmt::removeMemoryAccesses(MemoryAccessList &InvMAs) {
-
- // Remove all memory accesses in @p InvMAs from this statement together
- // with all scalar accesses that were caused by them. The tricky iteration
- // order uses is needed because the MemAccs is a vector and the order in
- // which the accesses of each memory access list (MAL) are stored in this
- // vector is reversed.
+ // Remove all memory accesses in @p InvMAs from this statement
+ // together with all scalar accesses that were caused by them.
for (MemoryAccess *MA : InvMAs) {
- auto &MAL = *lookupAccessesFor(MA->getAccessInstruction());
- MAL.reverse();
-
- auto MALIt = MAL.begin();
- auto MALEnd = MAL.end();
- auto MemAccsIt = MemAccs.begin();
- while (MALIt != MALEnd) {
- while (*MemAccsIt != *MALIt)
- MemAccsIt++;
-
- MALIt++;
- MemAccs.erase(MemAccsIt);
- }
-
+ auto Predicate = [&](MemoryAccess *Acc) {
+ return Acc == MA ||
+ Acc->getAccessInstruction() == MA->getAccessInstruction();
+ };
+ MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate),
+ MemAccs.end());
InstructionToAccess.erase(MA->getAccessInstruction());
- delete &MAL;
+ delete lookupAccessesFor(MA->getAccessInstruction());
}
}
OpenPOWER on IntegriCloud