[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.
This commit is contained in:
Benjamin Maxwell 2025-05-02 10:23:39 +01:00 committed by GitHub
parent daa4061d61
commit 40edb37bb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -287,8 +287,10 @@ void StackSlotColoring::InitializeSlots() {
auto StackID = MFI->getStackID(FI); auto StackID = MFI->getStackID(FI);
if (StackID != 0) { if (StackID != 0) {
AllColors.resize(StackID + 1); if (StackID >= AllColors.size()) {
UsedColors.resize(StackID + 1); AllColors.resize(StackID + 1);
UsedColors.resize(StackID + 1);
}
AllColors[StackID].resize(LastFI); AllColors[StackID].resize(LastFI);
UsedColors[StackID].resize(LastFI); UsedColors[StackID].resize(LastFI);
} }