From c07fdae33f083f6337a2810c36d6dcb2dbeacff2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Apr 2010 23:38:50 -0700 Subject: [PATCH 1/3] Fix incorrect comments in function inliner. --- ir_function_inlining.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 385ce9ef6d7..c623cd010b6 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -389,15 +389,15 @@ ir_call::generate_inline(ir_instruction *next_ir) next_ir->insert_before(v.result); } - /* Generate the declarations for the parameters to our inlined code, - * and set up the mapping of real function body variables to ours. + /* Copy back the value of any 'out' parameters from the function body + * variables to our own. */ i = 0; param_iter = this->actual_parameters.iterator(); for (i = 0; i < num_parameters; i++) { ir_instruction *const param = (ir_instruction *) param_iter.get(); - /* Move the actual param into our param variable if it's an 'in' type. */ + /* Move our param variable into the actual param if it's an 'out' type. */ if (parameters[i]->mode == ir_var_out || parameters[i]->mode == ir_var_inout) { ir_assignment *assign; From 05ddebac0a45bf07fa60b04b22f29234ca26a4a4 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 1 May 2010 00:31:35 -0700 Subject: [PATCH 2/3] Fix ir_return cloning to actually use the cloned subexpression. This caused a nasty bug where the function inliner would create new variables for each of the formal parameters, but the body would still reference the old copies. This was highly visible since the dead code eliminator (rightly) removed the new declarations, leading to printed IR that referenced non-existent variable names. --- ir_function_inlining.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index c623cd010b6..0d072c1b764 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -264,8 +264,7 @@ ir_function_cloning_visitor::visit(ir_return *ir) rval = this->result->as_rvalue(); assert(rval); - result = new ir_assignment(new ir_dereference(this->retval), - ir->get_value(), NULL); + result = new ir_assignment(new ir_dereference(this->retval), rval, NULL); } From b0e0da5f07b5072d588ab33b121933c705f3b8a1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 28 Apr 2010 23:18:25 -0700 Subject: [PATCH 3/3] Use %p rather than %08x when printing pointers to fix compile. --- ir_print_visitor.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 9edb6803853..ee7aa311758 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -34,9 +34,8 @@ _mesa_print_ir(exec_list *instructions, for (unsigned i = 0; i < state->num_user_structures; i++) { const glsl_type *const s = state->user_structures[i]; - printf("(structure (%s) (%s@%08x) (%u) (\n", - s->name, s->name, (unsigned) s, s->length - ); + printf("(structure (%s) (%s@%p) (%u) (\n", + s->name, s->name, s, s->length); for (unsigned j = 0; j < s->length; j++) { printf("\t(("); @@ -66,7 +65,7 @@ print_type(const glsl_type *t) printf(" %u)", t->length); } else if ((t->base_type == GLSL_TYPE_STRUCT) && (strncmp("gl_", t->name, 3) != 0)) { - printf("%s@%08x", t->name, (unsigned) t); + printf("%s@%p", t->name, t); } else { printf("%s", t->name); }