From: Eric Anholt Date: Thu, 24 Jun 2010 22:13:03 +0000 (-0700) Subject: Merge remote branch 'cworth/master' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e33c10328caec29616a5433b1d1df9088f3a84df;p=mesa.git Merge remote branch 'cworth/master' Conflicts: ast_to_hir.cpp ir.cpp This brings in the talloc-based memory management work, so that the compiler (almost) no longer leaks memory. --- e33c10328caec29616a5433b1d1df9088f3a84df diff --cc ast_to_hir.cpp index 25bbe2f2def,ddd4b732662..33eb27533fd --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@@ -519,17 -522,16 +522,19 @@@ do_assignment(exec_list *instructions, * temporary and return a deref of that temporary. If the rvalue * ends up not being used, the temp will get copy-propagated out. */ - ir_variable *var = new ir_variable(rhs->type, "assignment_tmp"); + ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp"); - instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), ++ ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var); + instructions->push_tail(var); - instructions->push_tail(new ir_assignment(new ir_dereference_variable(var), - rhs, - NULL)); ++ instructions->push_tail(new(ctx) ir_assignment(deref_var, + rhs, + NULL)); ++ deref_var = new(ctx) ir_dereference_variable(var); - instructions->push_tail(new ir_assignment(lhs, - new ir_dereference_variable(var), - NULL)); + instructions->push_tail(new(ctx) ir_assignment(lhs, - new(ctx) ir_dereference_variable(var), ++ deref_var, + NULL)); - return new ir_dereference_variable(var); + return new(ctx) ir_dereference_variable(var); } diff --cc ir_clone.cpp index 6db5073f75f,5ffd3fc00b2..84176383fca --- a/ir_clone.cpp +++ b/ir_clone.cpp @@@ -238,36 -251,3 +251,37 @@@ ir_function_signature::clone(struct has /* FINISHME */ abort(); } + +ir_instruction * +ir_constant::clone(struct hash_table *ht) const +{ ++ void *ctx = talloc_parent(this); + (void)ht; + + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: - return new ir_constant(this->type, &this->value); ++ return new(ctx) ir_constant(this->type, &this->value); + + case GLSL_TYPE_STRUCT: { - ir_constant *c = new ir_constant; ++ ir_constant *c = new(ctx) ir_constant; + + c->type = this->type; + for (exec_node *node = this->components.head + ; !node->is_tail_sentinal() + ; node = node->next) { + ir_constant *const orig = (ir_constant *) node; + + c->components.push_tail(orig->clone(NULL)); + } + + return c; + } + + default: + assert(!"Should not get here."); break; + return NULL; + } +} diff --cc ir_function_inlining.cpp index 851c0dd9f7b,8a1cf4f1d24..e55780c940e --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@@ -91,26 -91,6 +91,27 @@@ do_function_inlining(exec_list *instruc return v.progress; } +static void +replace_return_with_assignment(ir_instruction *ir, void *data) +{ ++ void *ctx = talloc_parent(ir); + ir_variable *retval = (ir_variable *)data; + ir_return *ret = ir->as_return(); + + if (ret) { + if (ret->value) { - ir_rvalue *lhs = new ir_dereference_variable(retval); - ret->insert_before(new ir_assignment(lhs, ret->value, NULL)); ++ ir_rvalue *lhs = new(ctx) ir_dereference_variable(retval); ++ ret->insert_before(new(ctx) ir_assignment(lhs, ret->value, NULL)); + ret->remove(); + } else { + /* un-valued return has to be the last return, or we shouldn't + * have reached here. (see can_inline()). + */ + assert(!ret->next->is_tail_sentinal()); + } + } +} + ir_rvalue * ir_call::generate_inline(ir_instruction *next_ir) { @@@ -150,12 -130,12 +152,12 @@@ next_ir->insert_before(parameters[i]); /* Move the actual param into our param variable if it's an 'in' type. */ - if (parameters[i]->mode == ir_var_in || - parameters[i]->mode == ir_var_inout) { + if (sig_param->mode == ir_var_in || + sig_param->mode == ir_var_inout) { ir_assignment *assign; - assign = new ir_assignment(new ir_dereference_variable(parameters[i]), - param, NULL); + assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]), + param, NULL); next_ir->insert_before(assign); }