Mesa (staging/21.1): aco/ra: Fix off-by-one-error in print_regs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 10 11:32:25 UTC 2021


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

Author: Tony Wasserka <tony.wasserka at gmx.de>
Date:   Thu Apr 29 18:06:53 2021 +0200

aco/ra: Fix off-by-one-error in print_regs

Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Fixes: 3675aefa84e ("aco/ra: Fix build with print_regs enabled")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10517>
(cherry picked from commit 5bfef2de66be739a54e64275feaa42c2d340b548)

---

 .pick_status.json                            | 2 +-
 src/amd/compiler/aco_register_allocation.cpp | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 9cbf496e2dc..2a82579f19f 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -922,7 +922,7 @@
         "description": "aco/ra: Fix off-by-one-error in print_regs",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "3675aefa84e363d820a3e596b9f2795a0d51c39f"
     },
diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp
index 3b71c39e438..5e620b3048f 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -355,8 +355,7 @@ private:
 /* helper function for debugging */
 UNUSED void print_regs(ra_ctx& ctx, bool vgprs, RegisterFile& reg_file)
 {
-   unsigned max = vgprs ? ctx.program->max_reg_demand.vgpr : ctx.program->max_reg_demand.sgpr;
-   PhysRegInterval regs { vgprs ? PhysReg{256} : PhysReg{0}, max };
+   PhysRegInterval regs = get_reg_bounds(ctx.program, vgprs ? RegType::vgpr : RegType::sgpr);
    char reg_char = vgprs ? 'v' : 's';
 
    /* print markers */
@@ -387,7 +386,7 @@ UNUSED void print_regs(ra_ctx& ctx, bool vgprs, RegisterFile& reg_file)
    }
    printf("\n");
 
-   printf("%u/%u used, %u/%u free\n", max - free_regs, max, free_regs, max);
+   printf("%u/%u used, %u/%u free\n", regs.size - free_regs, regs.size, free_regs, regs.size);
 
    /* print assignments */
    prev = 0;



More information about the mesa-commit mailing list