X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglsl%2Fopt_copy_propagation.cpp;h=806027b280ea9d39e80f8b681a0e0bcf2d06460a;hb=781badee7a46c7eb778fb2755d799151d8b748bf;hp=3a73342683b06151b2b8be0488424af594c64076;hpb=838a6871bbcd8cd0493bb39b188129f7d49de47e;p=mesa.git diff --git a/src/glsl/opt_copy_propagation.cpp b/src/glsl/opt_copy_propagation.cpp index 3a73342683b..806027b280e 100644 --- a/src/glsl/opt_copy_propagation.cpp +++ b/src/glsl/opt_copy_propagation.cpp @@ -128,6 +128,9 @@ ir_copy_propagation_visitor::visit_enter(ir_function_signature *ir) visit_list_elements(this, &ir->body); + ralloc_free(this->acp); + ralloc_free(this->kills); + this->kills = orig_kills; this->acp = orig_acp; this->killed_all = orig_killed_all; @@ -167,9 +170,7 @@ ir_copy_propagation_visitor::visit(ir_dereference_variable *ir) ir_variable *var = ir->var; - foreach_list(n, this->acp) { - acp_entry *entry = (acp_entry *) n; - + foreach_in_list(acp_entry, entry, this->acp) { if (var == entry->lhs) { ir->var = entry->rhs; this->progress = true; @@ -185,15 +186,14 @@ ir_visitor_status ir_copy_propagation_visitor::visit_enter(ir_call *ir) { /* Do copy propagation on call parameters, but skip any out params */ - exec_list_iterator sig_param_iter = ir->callee->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, ir->actual_parameters) { - ir_variable *sig_param = (ir_variable *)sig_param_iter.get(); - ir_instruction *ir = (ir_instruction *)iter.get(); + foreach_two_lists(formal_node, &ir->callee->parameters, + actual_node, &ir->actual_parameters) { + ir_variable *sig_param = (ir_variable *) formal_node; + ir_rvalue *ir = (ir_rvalue *) actual_node; if (sig_param->data.mode != ir_var_function_out && sig_param->data.mode != ir_var_function_inout) { ir->accept(this); } - sig_param_iter.next(); } /* Since we're unlinked, we don't (necessarily) know the side effects of @@ -217,9 +217,8 @@ ir_copy_propagation_visitor::handle_if_block(exec_list *instructions) this->killed_all = false; /* Populate the initial acp with a copy of the original */ - foreach_list(n, orig_acp) { - acp_entry *a = (acp_entry *) n; - this->acp->push_tail(new(this->mem_ctx) acp_entry(a->lhs, a->rhs)); + foreach_in_list(acp_entry, a, orig_acp) { + this->acp->push_tail(new(this->acp) acp_entry(a->lhs, a->rhs)); } visit_list_elements(this, instructions); @@ -230,13 +229,15 @@ ir_copy_propagation_visitor::handle_if_block(exec_list *instructions) exec_list *new_kills = this->kills; this->kills = orig_kills; + ralloc_free(this->acp); this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - foreach_list(n, new_kills) { - kill_entry *k = (kill_entry *) n; + foreach_in_list(kill_entry, k, new_kills) { kill(k->var); } + + ralloc_free(new_kills); } ir_visitor_status @@ -274,14 +275,16 @@ ir_copy_propagation_visitor::visit_enter(ir_loop *ir) exec_list *new_kills = this->kills; this->kills = orig_kills; + ralloc_free(this->acp); this->acp = orig_acp; this->killed_all = this->killed_all || orig_killed_all; - foreach_list(n, new_kills) { - kill_entry *k = (kill_entry *) n; + foreach_in_list(kill_entry, k, new_kills) { kill(k->var); } + ralloc_free(new_kills); + /* already descended into the children. */ return visit_continue_with_parent; } @@ -292,9 +295,7 @@ ir_copy_propagation_visitor::kill(ir_variable *var) assert(var != NULL); /* Remove any entries currently in the ACP for this kill. */ - foreach_list_safe(n, acp) { - acp_entry *entry = (acp_entry *) n; - + foreach_in_list_safe(acp_entry, entry, acp) { if (entry->lhs == var || entry->rhs == var) { entry->remove(); } @@ -302,7 +303,7 @@ ir_copy_propagation_visitor::kill(ir_variable *var) /* Add the LHS variable to the list of killed variables in this block. */ - this->kills->push_tail(new(this->mem_ctx) kill_entry(var)); + this->kills->push_tail(new(this->kills) kill_entry(var)); } /** @@ -330,7 +331,7 @@ ir_copy_propagation_visitor::add_copy(ir_assignment *ir) ir->condition = new(ralloc_parent(ir)) ir_constant(false); this->progress = true; } else { - entry = new(this->mem_ctx) acp_entry(lhs_var, rhs_var); + entry = new(this->acp) acp_entry(lhs_var, rhs_var); this->acp->push_tail(entry); } }