From 9d20cf27326a2ed948182de75dc2c865ff0e7544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Wed, 1 Sep 2021 08:40:45 +0200 Subject: [PATCH] aco: Fix invalid usage of std::fill with std::array. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: --- src/amd/compiler/aco_optimizer_postRA.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_optimizer_postRA.cpp b/src/amd/compiler/aco_optimizer_postRA.cpp index 84ee6ef01c7..4c385174b0b 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); } }