Skip to content

Commit a237866

Browse files
author
Andrew Kaylor
committed
Fix a block copying problem in LICM
Differential Revision: https://reviews.llvm.org/D44817 llvm-svn: 328336
1 parent 51dba7d commit a237866

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,14 @@ static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT,
893893
// Since we do not allow splitting EH-block with BlockColors in
894894
// canSplitPredecessors(), we can simply assign predecessor's color to
895895
// the new block.
896-
if (!BlockColors.empty())
897-
BlockColors[NewPred] = BlockColors[PredBB];
896+
if (!BlockColors.empty()) {
897+
// Grab a reference to the ColorVector to be inserted before getting the
898+
// reference to the vector we are copying because inserting the new
899+
// element in BlockColors might cause the map to be reallocated.
900+
ColorVector &ColorsForNewBlock = BlockColors[NewPred];
901+
ColorVector &ColorsForOldBlock = BlockColors[PredBB];
902+
ColorsForNewBlock = ColorsForOldBlock;
903+
}
898904
}
899905
PredBBs.remove(PredBB);
900906
}

0 commit comments

Comments
 (0)