Commit b4ef8aac by Jason Merrill Committed by Jason Merrill

re PR c++/23372 (Temporary aggregate copy not elided when passing parameters by value)

	PR c++/23372
	* gimplify.c (gimplify_arg): Strip redundant TARGET_EXPR.

From-SVN: r171146
parent 82d37118
2011-03-18 Jason Merrill <jason@redhat.com>
PR c++/23372
* gimplify.c (gimplify_arg): Strip redundant TARGET_EXPR.
2011-03-18 Richard Guenther <rguenther@suse.de> 2011-03-18 Richard Guenther <rguenther@suse.de>
* doc/install.texi (--enable-gold): Remove. * doc/install.texi (--enable-gold): Remove.
......
...@@ -2255,7 +2255,17 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location) ...@@ -2255,7 +2255,17 @@ gimplify_arg (tree *arg_p, gimple_seq *pre_p, location_t call_location)
if (is_gimple_reg_type (TREE_TYPE (*arg_p))) if (is_gimple_reg_type (TREE_TYPE (*arg_p)))
test = is_gimple_val, fb = fb_rvalue; test = is_gimple_val, fb = fb_rvalue;
else else
test = is_gimple_lvalue, fb = fb_either; {
test = is_gimple_lvalue, fb = fb_either;
/* Also strip a TARGET_EXPR that would force an extra copy. */
if (TREE_CODE (*arg_p) == TARGET_EXPR)
{
tree init = TARGET_EXPR_INITIAL (*arg_p);
if (init
&& !VOID_TYPE_P (TREE_TYPE (init)))
*arg_p = init;
}
}
/* If this is a variable sized type, we must remember the size. */ /* If this is a variable sized type, we must remember the size. */
maybe_with_size_expr (arg_p); maybe_with_size_expr (arg_p);
......
2011-03-18 Jason Merrill <jason@redhat.com> 2011-03-18 Jason Merrill <jason@redhat.com>
* g++.dg/opt/pr23372.C: New.
* g++.dg/ext/attrib32.C: Expect errors on the two-names case. * g++.dg/ext/attrib32.C: Expect errors on the two-names case.
2011-03-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-03-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
......
// PR c++/23372
// { dg-options -fdump-tree-gimple }
// There shouldn't be an assignment to a temporary in the GIMPLE,
// as that represents a redundant copy.
// { dg-final { scan-tree-dump-not "=" gimple } }
struct A {
int a[1000];
//A(A const &);
};
void f(A);
void g(A *a) { f(*a); }
// { dg-final { cleanup-tree-dump gimple } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment