Mesa (staging/21.2): ir3/ra: Check register file upper bound when updating preferred_reg

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 29 16:34:59 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: e8fd3214dc545d5b6055f9592a91691a40fc757f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8fd3214dc545d5b6055f9592a91691a40fc757f

Author: Danylo Piliaiev <dpiliaiev at igalia.com>
Date:   Wed Oct 27 13:40:51 2021 +0300

ir3/ra: Check register file upper bound when updating preferred_reg

Otherwise we could get invalid reg in get_reg()

Would fix many dEQP-VK.ssbo.phys.layout.*

Fixes: 0ffcb19b9d9fbe902224542047c389a661fbf816 "ir3: Rewrite register allocation"

Signed-off-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13546>
(cherry picked from commit aa264ded948defc88930eea7d54800b3188a3ac0)

---

 .pick_status.json          | 2 +-
 src/freedreno/ir3/ir3_ra.c | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index df3ab1e2f11..b89ca1fdf59 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -823,7 +823,7 @@
         "description": "ir3/ra: Check register file upper bound when updating preferred_reg",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "0ffcb19b9d9fbe902224542047c389a661fbf816"
     },
diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c
index b92155cdc3b..2ef061b648e 100644
--- a/src/freedreno/ir3/ir3_ra.c
+++ b/src/freedreno/ir3/ir3_ra.c
@@ -944,7 +944,8 @@ compress_regs_left(struct ra_ctx *ctx, struct ra_file *file, unsigned size,
 }
 
 static void
-update_affinity(struct ir3_register *reg, physreg_t physreg)
+update_affinity(struct ra_file *file, struct ir3_register *reg,
+                physreg_t physreg)
 {
    if (!reg->merge_set || reg->merge_set->preferred_reg != (physreg_t)~0)
       return;
@@ -952,6 +953,9 @@ update_affinity(struct ir3_register *reg, physreg_t physreg)
    if (physreg < reg->merge_set_offset)
       return;
 
+   if ((physreg - reg->merge_set_offset + reg->merge_set->size) > file->size)
+      return;
+
    reg->merge_set->preferred_reg = physreg - reg->merge_set_offset;
 }
 
@@ -1144,8 +1148,9 @@ static void
 allocate_dst_fixed(struct ra_ctx *ctx, struct ir3_register *dst,
                    physreg_t physreg)
 {
+   struct ra_file *file = ra_get_file(ctx, dst);
    struct ra_interval *interval = &ctx->intervals[dst->name];
-   update_affinity(dst, physreg);
+   update_affinity(file, dst, physreg);
 
    ra_interval_init(interval, dst);
    interval->physreg_start = physreg;



More information about the mesa-commit mailing list