aco: reduce memory usage of live_var_analysis

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39408>
This commit is contained in:
Rhys Perry 2026-01-21 10:28:35 +00:00 committed by Marge Bot
parent 874255e899
commit 2c9775b339
2 changed files with 34 additions and 0 deletions

View file

@ -193,6 +193,8 @@ get_demand_for_reg(live_ctx& ctx, T op_or_def)
void
process_live_temps_per_block(live_ctx& ctx, Block* block)
{
ctx.m.release_reallocate();
RegisterDemand new_demand;
unsigned num_linear_vgprs = 0;
block->register_demand = RegisterDemand();

View file

@ -298,6 +298,38 @@ public:
buffer->current_idx = 0;
}
/* Release all memory, with the expectation that a similar amount will be allocated again. */
void release_reallocate()
{
size_t size = 0;
for (Buffer* buf = buffer; buf; buf = buf->next)
size += buf->current_idx;
if (buffer->data_size >= size) {
Buffer* buf = buffer->next;
while (buf) {
Buffer* next = buf->next;
free(buf);
buf = next;
}
buffer->next = NULL;
buffer->current_idx = 0;
return;
}
release();
free(buffer);
size_t total_size = initial_size;
do {
total_size *= 2;
} while (total_size - sizeof(Buffer) < size);
buffer = (Buffer*)malloc(total_size);
buffer->next = NULL;
buffer->data_size = total_size - sizeof(Buffer);
buffer->current_idx = 0;
}
bool operator==(const monotonic_buffer_resource& other) const { return buffer == other.buffer; }
private: