[PATCH] D44817: Fix a block color copying problem in LICM

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 10:39:36 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL328336: Fix a block copying problem in LICM (authored by akaylor, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44817?vs=139558&id=139611#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44817

Files:
  llvm/trunk/lib/Transforms/Scalar/LICM.cpp


Index: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp
@@ -893,8 +893,14 @@
       // Since we do not allow splitting EH-block with BlockColors in
       // canSplitPredecessors(), we can simply assign predecessor's color to
       // the new block.
-      if (!BlockColors.empty())
-        BlockColors[NewPred] = BlockColors[PredBB];
+      if (!BlockColors.empty()) {
+        // Grab a reference to the ColorVector to be inserted before getting the
+        // reference to the vector we are copying because inserting the new
+        // element in BlockColors might cause the map to be reallocated.
+        ColorVector &ColorsForNewBlock = BlockColors[NewPred];
+        ColorVector &ColorsForOldBlock = BlockColors[PredBB];
+        ColorsForNewBlock = ColorsForOldBlock;
+      }
     }
     PredBBs.remove(PredBB);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44817.139611.patch
Type: text/x-patch
Size: 983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180323/67dd2e0e/attachment.bin>


More information about the llvm-commits mailing list