ir3/ra: Make sure we don't pick a preferred reg overflowing the file.

If we're in handle_collect()'s dst allocation and are part of a merge set
near the end of the file, our check for reg_elem_size(reg) would let us
use the preferred reg when that would immediately lead to
allocate_dst_fixed() creating an interval extending thruogh reg_size(reg)
that overflows the file.

Avoids a regression on gfxbench5/gl_5_high_off/17.shader_test in the next
commit.  No change on shader-db.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18946>
(cherry picked from commit a39113b616)
This commit is contained in:
Emma Anholt
2022-11-09 12:23:53 -08:00
committed by Dylan Baker
parent 06c5579f32
commit ef204ae80a
2 changed files with 2 additions and 2 deletions

View File

@@ -1300,7 +1300,7 @@
"description": "ir3/ra: Make sure we don't pick a preferred reg overflowing the file.",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View File

@@ -1374,7 +1374,7 @@ get_reg(struct ra_ctx *ctx, struct ra_file *file, struct ir3_register *reg)
if (reg->merge_set && reg->merge_set->preferred_reg != (physreg_t)~0) {
physreg_t preferred_reg =
reg->merge_set->preferred_reg + reg->merge_set_offset;
if (preferred_reg < file_size &&
if (preferred_reg + reg_size(reg) <= file_size &&
preferred_reg % reg_elem_size(reg) == 0 &&
get_reg_specified(ctx, file, reg, preferred_reg, false))
return preferred_reg;