[llvm] r289757 - Fix iterator-invalidation issue

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 19:30:40 PST 2016


Author: hfinkel
Date: Wed Dec 14 21:30:40 2016
New Revision: 289757

URL: http://llvm.org/viewvc/llvm-project?rev=289757&view=rev
Log:
Fix iterator-invalidation issue

Inserting a new key into a DenseMap potentially invalidates iterators into that
map. Trying to fix an issue from r289755 triggering this assertion:

  Assertion `isHandleInSync() && "invalid iterator access!"' failed.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=289757&r1=289756&r2=289757&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Dec 14 21:30:40 2016
@@ -3529,7 +3529,9 @@ void ScalarEvolution::addAffectedFromOpe
       if (AMI == AffectedMap.end())
         continue;
 
-      AffectedMap[S].insert(AMI->second.begin(), AMI->second.end());
+      auto &ISet = AffectedMap[S];
+      AMI = AffectedMap.find(Op);
+      ISet.insert(AMI->second.begin(), AMI->second.end());
     }
 }
 




More information about the llvm-commits mailing list