intel: fix leaking memory on shader creation

ralloc_adopt takes care of all the shader's children, but shader itsel ends up
orphaned and never gets free'd.

Fixes: ef5bce9253 ("intel: Drop the last uses of a mem_ctx in nir_builder_init_simple_shader().")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4951

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11651>
(cherry picked from commit 974c58b317)
This commit is contained in:
Yevhenii Kolesnikov 2021-06-29 18:49:42 +03:00 committed by Eric Engestrom
parent f1c531aa65
commit ec910d2e24
3 changed files with 3 additions and 3 deletions

View file

@ -4882,7 +4882,7 @@
"description": "intel: fix leaking memory on shader creation",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "ef5bce9253e2221ef8df0764447cb02c02fa2a16"
},

View file

@ -30,7 +30,7 @@ blorp_nir_init_shader(nir_builder *b,
const char *name)
{
*b = nir_builder_init_simple_shader(stage, NULL, "%s", name ? name : "");
ralloc_adopt(mem_ctx, b->shader);
ralloc_steal(mem_ctx, b->shader);
if (stage == MESA_SHADER_FRAGMENT)
b->shader->info.fs.origin_upper_left = true;
}

View file

@ -1504,7 +1504,7 @@ brw_nir_create_passthrough_tcs(void *mem_ctx, const struct brw_compiler *compile
{
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_TESS_CTRL,
options, "passthrough TCS");
ralloc_adopt(mem_ctx, b.shader);
ralloc_steal(mem_ctx, b.shader);
nir_shader *nir = b.shader;
nir_variable *var;
nir_ssa_def *load;