diff --git a/llvm/lib/CodeGen/StackSlotColoring.cpp b/llvm/lib/CodeGen/StackSlotColoring.cpp index 6e1c9fd16717..2f81bea4e86b 100644 --- a/llvm/lib/CodeGen/StackSlotColoring.cpp +++ b/llvm/lib/CodeGen/StackSlotColoring.cpp @@ -287,8 +287,10 @@ void StackSlotColoring::InitializeSlots() { auto StackID = MFI->getStackID(FI); if (StackID != 0) { - AllColors.resize(StackID + 1); - UsedColors.resize(StackID + 1); + if (StackID >= AllColors.size()) { + AllColors.resize(StackID + 1); + UsedColors.resize(StackID + 1); + } AllColors[StackID].resize(LastFI); UsedColors[StackID].resize(LastFI); }