diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index bf8f2747146..d1064e278ff 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -2231,9 +2231,6 @@ opt_shader(const struct gl_constants *consts, do_vec_index_to_cond_assign(shader->ir); validate_ir_tree(shader->ir); - - /* Retain any live IR, but trash the rest. */ - reparent_ir(shader->ir, shader->ir); } static bool @@ -2422,9 +2419,6 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, } } - delete state->symbols; - ralloc_free(state); - if (ctx->_Shader && ctx->_Shader->Flags & GLSL_DUMP) { if (shader->CompileStatus) { assert(shader->ir); @@ -2454,6 +2448,9 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, source_blake3); } + delete state->symbols; + ralloc_free(state); + if (ctx->Cache && shader->CompileStatus == COMPILE_SUCCESS) { char sha1_buf[41]; disk_cache_put_key(ctx->Cache, shader->disk_cache_sha1); diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp index 71c0a214b58..4212e522761 100644 --- a/src/compiler/glsl/ir.cpp +++ b/src/compiler/glsl/ir.cpp @@ -2191,44 +2191,6 @@ visit_exec_list_safe(ir_exec_list *list, ir_visitor *visitor) } } - -static void -steal_memory(ir_instruction *ir, void *new_ctx) -{ - ir_variable *var = ir->as_variable(); - ir_function *fn = ir->as_function(); - ir_constant *constant = ir->as_constant(); - if (var != NULL && var->constant_value != NULL) - steal_memory(var->constant_value, ir); - - if (var != NULL && var->constant_initializer != NULL) - steal_memory(var->constant_initializer, ir); - - if (fn != NULL && fn->subroutine_types) - ralloc_steal(new_ctx, fn->subroutine_types); - - /* The components of aggregate constants are not visited by the normal - * visitor, so steal their values by hand. - */ - if (constant != NULL && - (glsl_type_is_array(constant->type) || glsl_type_is_struct(constant->type))) { - for (unsigned int i = 0; i < constant->type->length; i++) { - steal_memory(constant->const_elements[i], ir); - } - } - - ralloc_steal(new_ctx, ir); -} - - -void -reparent_ir(ir_exec_list *list, void *mem_ctx) -{ - ir_foreach_in_list(ir_instruction, node, list) { - visit_tree(node, steal_memory, mem_ctx); - } -} - enum mesa_prim gl_to_mesa_prim(GLenum prim) { diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index e2a6c701715..900c15245a3 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -2440,9 +2440,6 @@ detect_recursion_unlinked(struct _mesa_glsl_parse_state *state, void clone_ir_list(void *mem_ctx, ir_exec_list *out, const ir_exec_list *in); -extern void -reparent_ir(ir_exec_list *list, void *mem_ctx); - extern char * prototype_string(const glsl_type *return_type, const char *name, ir_exec_list *parameters);