[llvm] [StackSlotColoring] Fix a latent bug (PR #138140)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Thu May 1 07:22:18 PDT 2025
https://github.com/MacDue created https://github.com/llvm/llvm-project/pull/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 loose BitVector associated with A.
>From 0057c9145e5007f2ffc0e5623c48b07e0bbb41d7 Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: Thu, 1 May 2025 10:33:44 +0000
Subject: [PATCH] [StackSlotColoring] Fix a latent bug
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 loose BitVector
associated with A.
---
llvm/lib/CodeGen/StackSlotColoring.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/StackSlotColoring.cpp b/llvm/lib/CodeGen/StackSlotColoring.cpp
index 6e1c9fd167174..2f81bea4e86ba 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);
}
More information about the llvm-commits
mailing list