[PATCH] D18440: Don't use potentially invalidated iterator

Stephan Bergmann via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 04:50:04 PDT 2016


sberg created this revision.
sberg added a reviewer: majnemer.
sberg added a subscriber: llvm-commits.

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.)

http://reviews.llvm.org/D18440

Files:
  lib/CodeGen/BranchFolding.cpp

Index: lib/CodeGen/BranchFolding.cpp
===================================================================
--- lib/CodeGen/BranchFolding.cpp
+++ lib/CodeGen/BranchFolding.cpp
@@ -453,8 +453,10 @@
 
   // 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()) {
+    const auto n = FuncletI->second;
+    FuncletMembership[NewMBB] = n;
+  }
 
   return NewMBB;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18440.51536.patch
Type: text/x-patch
Size: 538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160324/9323a669/attachment.bin>


More information about the llvm-commits mailing list