[llvm] r265024 - Don't use potentially invalidated iterator

Stephan Bergmann via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 08:42:01 PDT 2016


Author: sberg
Date: Thu Mar 31 10:42:01 2016
New Revision: 265024

URL: http://llvm.org/viewvc/llvm-project?rev=265024&view=rev
Log:
Don't use potentially invalidated iterator

If the lhs is evaluated before the rhs, FuncletI's operator-> can trigger the

  assert(isHandleInSync() && "invalid iterator access!");

at include/llvm/ADT/DenseMap.h:1061.  (Happens e.g. when compiled with GCC 6.)

Differential Revision: http://reviews.llvm.org/D18440

Modified:
    llvm/trunk/lib/CodeGen/BranchFolding.cpp

Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=265024&r1=265023&r2=265024&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Thu Mar 31 10:42:01 2016
@@ -453,8 +453,10 @@ MachineBasicBlock *BranchFolder::SplitMB
 
   // Add the new block to the funclet.
   const auto &FuncletI = FuncletMembership.find(&CurMBB);
-  if (FuncletI != FuncletMembership.end())
-    FuncletMembership[NewMBB] = FuncletI->second;
+  if (FuncletI != FuncletMembership.end()) {
+    auto n = FuncletI->second;
+    FuncletMembership[NewMBB] = n;
+  }
 
   return NewMBB;
 }




More information about the llvm-commits mailing list