From f7a71e2570053205eb603aa04b8c52d4f54d8e4c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 8 May 2012 13:40:44 -0700 Subject: [PATCH] i965/fs: When doing no work for live interval calculation, do no allocation. When I had a bug causing the backend to never finish optimizing, it also sent me deep into swap. This avoids extra memory allocation per trip through optimization, and thus may reduce the peak memory allocation of the driver even in the success case. Reviewed-by: Kenneth Graunke --- .../drivers/dri/i965/brw_fs_live_variables.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp index c6f0fbc009f..c7ee582c283 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp @@ -163,12 +163,17 @@ void fs_visitor::calculate_live_intervals() { int num_vars = this->virtual_grf_next; - int *def = ralloc_array(mem_ctx, int, num_vars); - int *use = ralloc_array(mem_ctx, int, num_vars); if (this->live_intervals_valid) return; + int *def = ralloc_array(mem_ctx, int, num_vars); + int *use = ralloc_array(mem_ctx, int, num_vars); + ralloc_free(this->virtual_grf_def); + ralloc_free(this->virtual_grf_use); + this->virtual_grf_def = def; + this->virtual_grf_use = use; + for (int i = 0; i < num_vars; i++) { def[i] = MAX_INSTRUCTION; use[i] = -1; @@ -215,11 +220,6 @@ fs_visitor::calculate_live_intervals() } } - ralloc_free(this->virtual_grf_def); - ralloc_free(this->virtual_grf_use); - this->virtual_grf_def = def; - this->virtual_grf_use = use; - this->live_intervals_valid = true; } -- 2.30.2