From 858162a2fcdfacf74fabceae2b56e6712ac40366 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sat, 9 Aug 2025 15:03:49 -0700 Subject: [PATCH] brw: Allocate brw_inst::src with ralloc In the few cases we have to _increase_ the number of sources, the new code will not attempt to recollect the memory, i.e. it delays freeing the old smaller one source array. For the instructions that may need this (when making a SEND into a SEND_GATHER), this is not expected to happen more than once. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_inst.cpp | 15 +++------------ src/intel/compiler/brw_inst.h | 1 - 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/intel/compiler/brw_inst.cpp b/src/intel/compiler/brw_inst.cpp index d265b4f27f5..78843432de1 100644 --- a/src/intel/compiler/brw_inst.cpp +++ b/src/intel/compiler/brw_inst.cpp @@ -81,17 +81,11 @@ brw_inst::brw_inst(const brw_inst &that) initialize_sources(this, that.src, that.sources); } -brw_inst::~brw_inst() -{ - if (this->src != this->builtin_src) - delete[] this->src; -} - static void initialize_sources(brw_inst *inst, const brw_reg src[], uint8_t num_sources) { if (num_sources > ARRAY_SIZE(inst->builtin_src)) - inst->src = new brw_reg[num_sources]; + inst->src = ralloc_array(inst, brw_reg, num_sources); else inst->src = inst->builtin_src; @@ -114,7 +108,7 @@ brw_inst::resize_sources(uint8_t num_sources) if (old_src == this->builtin_src) { if (num_sources > builtin_size) { - new_src = new brw_reg[num_sources]; + new_src = ralloc_array(this, brw_reg, num_sources); for (unsigned i = 0; i < this->sources; i++) new_src[i] = old_src[i]; @@ -132,13 +126,10 @@ brw_inst::resize_sources(uint8_t num_sources) new_src = old_src; } else { - new_src = new brw_reg[num_sources]; + new_src = ralloc_array(this, brw_reg, num_sources); for (unsigned i = 0; i < this->sources; i++) new_src[i] = old_src[i]; } - - if (old_src != new_src) - delete[] old_src; } this->sources = num_sources; diff --git a/src/intel/compiler/brw_inst.h b/src/intel/compiler/brw_inst.h index bd144481c28..22406e9754a 100644 --- a/src/intel/compiler/brw_inst.h +++ b/src/intel/compiler/brw_inst.h @@ -51,7 +51,6 @@ public: brw_inst(enum opcode opcode, uint8_t exec_size, const brw_reg &dst, const brw_reg src[], unsigned sources); brw_inst(const brw_inst &that); - ~brw_inst(); void resize_sources(uint8_t num_sources);