Fix ir_return cloning to actually use the cloned subexpression.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 1 May 2010 07:31:35 +0000 (00:31 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 1 May 2010 07:31:35 +0000 (00:31 -0700)
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

index c623cd010b63f2ec38b83033dc518123f068327d..0d072c1b764c8cbe477a36e026da2c091e24fb2f 100644 (file)
@@ -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);
 }