From dba75d345df2a96c3b37d8fb5c6c4fdc80df43de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Fri, 25 Nov 2022 10:31:36 +0200 Subject: [PATCH] nir: fix a leak of ralloc ctx in nir_opt_ray_query_ranges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes following leak: ==7520== 48 bytes in 1 blocks are definitely lost in loss record 1,597 of 2,016 ==7520== at 0x484486F: malloc (vg_replace_malloc.c:381) ==7520== by 0x5314A4E: ralloc_size (ralloc.c:117) ==7520== by 0x5314A1F: ralloc_context (ralloc.c:104) ==7520== by 0x6A95D68: nir_opt_ray_query_ranges (nir_opt_ray_queries.c:235) Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Fixes: f5b657658588 ("nir: Add a pass for combining ray queries") Part-of: --- src/compiler/nir/nir_opt_ray_queries.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opt_ray_queries.c b/src/compiler/nir/nir_opt_ray_queries.c index b7d7c8341cc64..a95e5173687e3 100644 --- a/src/compiler/nir/nir_opt_ray_queries.c +++ b/src/compiler/nir/nir_opt_ray_queries.c @@ -232,8 +232,6 @@ nir_opt_ray_query_ranges(nir_shader *shader) (struct nir_function *)exec_list_get_head_const(&shader->functions); assert(func->impl); - void *mem_ctx = ralloc_context(NULL); - uint32_t ray_query_count = 0; nir_foreach_variable_in_shader(var, shader) { if (!var->data.ray_query || glsl_type_is_array(var->type)) @@ -251,6 +249,8 @@ nir_opt_ray_query_ranges(nir_shader *shader) return false; } + void *mem_ctx = ralloc_context(NULL); + nir_metadata_require(func->impl, nir_metadata_instr_index | nir_metadata_dominance); nir_variable **ray_queries = ralloc_array(mem_ctx, nir_variable*, ray_query_count);