Mesa (main): lima/ppir: initialize spill_costs array in regalloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 11 22:03:19 UTC 2022


Module: Mesa
Branch: main
Commit: 2d807979c955d806ed16380b49c399d6f44a7972
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d807979c955d806ed16380b49c399d6f44a7972

Author: Erico Nunes <nunes.erico at gmail.com>
Date:   Fri Feb  4 20:36:20 2022 +0100

lima/ppir: initialize spill_costs array in regalloc

Static analysis complains that spill_costs might be accessed in
non-initialized positions.
It does not seem to be an issue with the current code which initializes
it for every relevant register index, but we can also just initialize it
to not have to worry about that.

Signed-off-by: Erico Nunes <nunes.erico at gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

---

 src/gallium/drivers/lima/ir/pp/regalloc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/lima/ir/pp/regalloc.c b/src/gallium/drivers/lima/ir/pp/regalloc.c
index 08cc3e76c85..e80d468313b 100644
--- a/src/gallium/drivers/lima/ir/pp/regalloc.c
+++ b/src/gallium/drivers/lima/ir/pp/regalloc.c
@@ -418,6 +418,7 @@ static ppir_reg *ppir_regalloc_choose_spill_node(ppir_compiler *comp,
     * but not too much as to offset the num_components base cost. */
    const float slot_scale = 1.1f;
 
+   memset(spill_costs, 0, sizeof(spill_costs[0]) * comp->reg_num);
    list_for_each_entry(ppir_reg, reg, &comp->reg_list, list) {
       if (reg->spilled) {
          /* not considered for spilling */



More information about the mesa-commit mailing list