From: Timur Kristóf Date: Wed, 1 Sep 2021 06:40:45 +0000 (+0200) Subject: aco: Fix invalid usage of std::fill with std::array. X-Git-Tag: upstream/22.3.5~18462 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d20cf27326a2ed948182de75dc2c865ff0e7544;p=platform%2Fupstream%2Fmesa.git aco: Fix invalid usage of std::fill with std::array. In this case std::array doesn't behave like a regular array, therefore it is NOT okay to index it outside the array, even though std::fill needs us to do so. Change the syntax to do the same thing slightly differently, and add an assertion to make sure the registers are always within the array's bounds. Closes: #5289 Fixes: 0e4747d3fb7ec15f8c1d6b971b1352249e7d95c6 Signed-off-by: Timur Kristóf Reviewed-by: Tony Wasserka Part-of: --- diff --git a/src/amd/compiler/aco_optimizer_postRA.cpp b/src/amd/compiler/aco_optimizer_postRA.cpp index 84ee6ef..4c38517 100644 --- a/src/amd/compiler/aco_optimizer_postRA.cpp +++ b/src/amd/compiler/aco_optimizer_postRA.cpp @@ -110,9 +110,10 @@ save_reg_writes(pr_opt_ctx& ctx, aco_ptr& instr) if (def.regClass().is_subdword()) idx = clobbered; + assert((r + dw_size) <= max_reg_cnt); assert(def.size() == dw_size || def.regClass().is_subdword()); std::fill(&ctx.instr_idx_by_regs[ctx.current_block->index][r], - &ctx.instr_idx_by_regs[ctx.current_block->index][r + dw_size], idx); + &ctx.instr_idx_by_regs[ctx.current_block->index][r] + dw_size, idx); } }