Skip to content

Commit 40edb37

Browse files
authored
[StackSlotColoring] Fix issue where colors for a StackID are dropped (#138140)
In InitializeSlots, if an interval with a non-zero StackID (A) is encountered we set All/UsedColors to a size of A + 1. If after this we process another interval with a non-zero StackID (B), where B < A, then we resize All/UsedColors to size < A + 1, and lose the BitVector associated with A. AFAIK this is a latent bug upstream, but when adding a new TargetStackID locally I hit a `NextColors[StackID] != -1 && "No more spill slots?"` assertion due to this issue.
1 parent daa4061 commit 40edb37

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/CodeGen/StackSlotColoring.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,10 @@ void StackSlotColoring::InitializeSlots() {
287287

288288
auto StackID = MFI->getStackID(FI);
289289
if (StackID != 0) {
290-
AllColors.resize(StackID + 1);
291-
UsedColors.resize(StackID + 1);
290+
if (StackID >= AllColors.size()) {
291+
AllColors.resize(StackID + 1);
292+
UsedColors.resize(StackID + 1);
293+
}
292294
AllColors[StackID].resize(LastFI);
293295
UsedColors[StackID].resize(LastFI);
294296
}

0 commit comments

Comments
 (0)