glsl2: Make the dead code handler make its own talloc context.
This way, we don't need to pass in a parse state, and the context doesn't grow with the number of passes through optimization.
This commit is contained in:
@@ -146,13 +146,12 @@ ir_dead_code_visitor::visit_leave(ir_assignment *ir)
|
||||
* for usage on an unlinked instruction stream.
|
||||
*/
|
||||
bool
|
||||
do_dead_code(struct _mesa_glsl_parse_state *state,
|
||||
exec_list *instructions)
|
||||
do_dead_code(exec_list *instructions)
|
||||
{
|
||||
ir_dead_code_visitor v;
|
||||
bool progress = false;
|
||||
|
||||
v.mem_ctx = state;
|
||||
v.mem_ctx = talloc_new(NULL);
|
||||
v.run(instructions);
|
||||
|
||||
foreach_iter(exec_list_iterator, iter, v.variable_list) {
|
||||
@@ -188,6 +187,8 @@ do_dead_code(struct _mesa_glsl_parse_state *state,
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
talloc_free(v.mem_ctx);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
@@ -199,8 +200,7 @@ do_dead_code(struct _mesa_glsl_parse_state *state,
|
||||
* with global scope.
|
||||
*/
|
||||
bool
|
||||
do_dead_code_unlinked(struct _mesa_glsl_parse_state *state,
|
||||
exec_list *instructions)
|
||||
do_dead_code_unlinked(exec_list *instructions)
|
||||
{
|
||||
bool progress = false;
|
||||
|
||||
@@ -211,7 +211,7 @@ do_dead_code_unlinked(struct _mesa_glsl_parse_state *state,
|
||||
foreach_iter(exec_list_iterator, sigiter, *f) {
|
||||
ir_function_signature *sig =
|
||||
(ir_function_signature *) sigiter.get();
|
||||
if (do_dead_code(state, &sig->body))
|
||||
if (do_dead_code(&sig->body))
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,9 @@ bool do_constant_folding(exec_list *instructions);
|
||||
bool do_constant_variable(exec_list *instructions);
|
||||
bool do_constant_variable_unlinked(exec_list *instructions);
|
||||
bool do_copy_propagation(exec_list *instructions);
|
||||
bool do_dead_code(struct _mesa_glsl_parse_state *state,
|
||||
exec_list *instructions);
|
||||
bool do_dead_code(exec_list *instructions);
|
||||
bool do_dead_code_local(exec_list *instructions);
|
||||
bool do_dead_code_unlinked(struct _mesa_glsl_parse_state *state,
|
||||
exec_list *instructions);
|
||||
bool do_dead_code_unlinked(exec_list *instructions);
|
||||
bool do_div_to_mul_rcp(exec_list *instructions);
|
||||
bool do_function_inlining(exec_list *instructions);
|
||||
bool do_if_return(exec_list *instructions);
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ compile_shader(struct gl_shader *shader)
|
||||
progress = do_if_simplification(shader->ir) || progress;
|
||||
progress = do_copy_propagation(shader->ir) || progress;
|
||||
progress = do_dead_code_local(shader->ir) || progress;
|
||||
progress = do_dead_code_unlinked(state, shader->ir) || progress;
|
||||
progress = do_dead_code_unlinked(shader->ir) || progress;
|
||||
progress = do_constant_variable_unlinked(shader->ir) || progress;
|
||||
progress = do_constant_folding(shader->ir) || progress;
|
||||
progress = do_algebraic(shader->ir) || progress;
|
||||
|
||||
@@ -2237,7 +2237,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
|
||||
progress = do_if_simplification(shader->ir) || progress;
|
||||
progress = do_copy_propagation(shader->ir) || progress;
|
||||
progress = do_dead_code_local(shader->ir) || progress;
|
||||
progress = do_dead_code_unlinked(state, shader->ir) || progress;
|
||||
progress = do_dead_code_unlinked(shader->ir) || progress;
|
||||
progress = do_constant_variable_unlinked(shader->ir) || progress;
|
||||
progress = do_constant_folding(shader->ir) || progress;
|
||||
progress = do_algebraic(shader->ir) || progress;
|
||||
|
||||
Reference in New Issue
Block a user