<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 29, 2015 at 9:36 PM, Tobias Grosser via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">grosser created this revision.<br>
grosser added reviewers: jdoerfert, Meinersbur.<br>
grosser added subscribers: llvm-commits, pollydev.<br>
<br>
The use of C++'s high-level iterator functionality instead of two while loops<br>
and explicit iterator handling improves readability of this code.<br>
<br>
This passes LNT -polly-process-unprofitable for me.<br>
<br>
Proposed-by: Michael Kruse <<a href="mailto:llvm@meinersbur.de">llvm@meinersbur.de</a>><br>
<br>
<a href="http://reviews.llvm.org/D15068" rel="noreferrer" target="_blank">http://reviews.llvm.org/D15068</a><br>
<br>
Files:<br>
lib/Analysis/ScopInfo.cpp<br>
<br>
Index: lib/Analysis/ScopInfo.cpp<br>
===================================================================<br>
--- lib/Analysis/ScopInfo.cpp<br>
+++ lib/Analysis/ScopInfo.cpp<br>
@@ -1464,28 +1464,18 @@<br>
void ScopStmt::dump() const { print(dbgs()); }<br>
<br>
void ScopStmt::removeMemoryAccesses(MemoryAccessList &InvMAs) {<br>
-<br>
- // Remove all memory accesses in @p InvMAs from this statement together<br>
- // with all scalar accesses that were caused by them. The tricky iteration<br>
- // order uses is needed because the MemAccs is a vector and the order in<br>
- // which the accesses of each memory access list (MAL) are stored in this<br>
- // vector is reversed.<br>
+ // Remove all memory accesses in @p InvMAs from this statement<br>
+ // together with all scalar accesses that were caused by them.<br>
for (MemoryAccess *MA : InvMAs) {<br>
- auto &MAL = *lookupAccessesFor(MA->getAccessInstruction());<br>
- MAL.reverse();<br>
-<br>
- auto MALIt = MAL.begin();<br>
- auto MALEnd = MAL.end();<br>
- auto MemAccsIt = MemAccs.begin();<br>
- while (MALIt != MALEnd) {<br>
- while (*MemAccsIt != *MALIt)<br>
- MemAccsIt++;<br>
-<br>
- MALIt++;<br>
- MemAccs.erase(MemAccsIt);<br>
- }<br>
-<br>
+ auto Predicate = [MA](MemoryAccess *Acc) -> bool {<br></blockquote><div><br>Just capture everything by ref here ^ ("[&]") since the lambda is being used in the scope (it's not leaking out via std::function, etc) so everything will be valid & it should just be treated like a normal scope.<br><br><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return (Acc == MA) ||<br></blockquote><div><br>Drop unneeded parens ^<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ (Acc->isWrite() &&<br>
+ Acc->getAccessInstruction() == MA->getAccessInstruction());<br>
+ };<br>
+ MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate),<br></blockquote><div><br></div><div>Probably just define the lambda directly inline without giving it a name?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ MemAccs.end());<br>
InstructionToAccess.erase(MA->getAccessInstruction());<br>
+ auto &MAL = *lookupAccessesFor(MA->getAccessInstruction());<br>
delete &MAL;<br></blockquote><div><br></div><div>Drop the local variable & pass the result of lookupAccessesFor to delete, without the dereference and address-of usage?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
}<br>
<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>