X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fopt_constant_variable.cpp;h=1bbaf8e4792085c520c80ca1a05fb3f2e0bf667f;hb=d7949eefcba39d48edd8af53f2d88d58f8cd5381;hp=9dca0ff8e76e85a6907f3f0d87c5a54f484a2978;hpb=29a2e9133e415de8b010df5b80db758aaf1007a6;p=mesa.git diff --git a/src/glsl/opt_constant_variable.cpp b/src/glsl/opt_constant_variable.cpp index 9dca0ff8e76..1bbaf8e4792 100644 --- a/src/glsl/opt_constant_variable.cpp +++ b/src/glsl/opt_constant_variable.cpp @@ -37,8 +37,7 @@ #include "ir_optimization.h" #include "glsl_types.h" -using std::calloc; -using std::free; +namespace { struct assignment_entry { exec_node link; @@ -58,6 +57,8 @@ public: exec_list list; }; +} /* unnamed namespace */ + static struct assignment_entry * get_assignment_entry(ir_variable *var, exec_list *list) { @@ -130,7 +131,8 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir) ir_visitor_status ir_constant_variable_visitor::visit_enter(ir_call *ir) { - exec_list_iterator sig_iter = ir->get_callee()->parameters.iterator(); + /* Mark any out parameters as assigned to */ + exec_list_iterator sig_iter = ir->callee->parameters.iterator(); foreach_iter(exec_list_iterator, iter, *ir) { ir_rvalue *param_rval = (ir_rvalue *)iter.get(); ir_variable *param = (ir_variable *)sig_iter.get(); @@ -146,6 +148,17 @@ ir_constant_variable_visitor::visit_enter(ir_call *ir) } sig_iter.next(); } + + /* Mark the return storage as having been assigned to */ + if (ir->return_deref != NULL) { + ir_variable *var = ir->return_deref->variable_referenced(); + struct assignment_entry *entry; + + assert(var); + entry = get_assignment_entry(var, &this->list); + entry->assignment_count++; + } + return visit_continue; }