From 92d7a6ab1c2f812f1b00ecad313ea1edc4fe7e53 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Mon, 19 Jul 2021 19:43:54 +0200 Subject: [PATCH] aco/spill: Avoid destroying local next use maps over-eagerly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recreating these maps in a later block requires allocating fresh memory. Instead, by never shrinking the containing vector in the first place, previously allocated map memory is now re-used. Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_spill.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 1965b53f4f7..c9b758eb0bd 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -360,7 +360,11 @@ void update_local_next_uses(spill_ctx& ctx, Block* block, std::vector>& local_next_uses) { - local_next_uses.resize(block->instructions.size()); + if (local_next_uses.size() < block->instructions.size()) { + /* Allocate more next-use-maps. Note that by never reducing the vector size, we enable + * future calls to this function to re-use already allocated map memory. */ + local_next_uses.resize(block->instructions.size()); + } local_next_uses[block->instructions.size() - 1].clear(); for (std::pair>& pair :