This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC (gimple): PATCH to really avoid copying empty classes (c++/43787)
- From: Jason Merrill <jason at redhat dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 05 May 2010 18:01:07 -0400
- Subject: Re: RFC (gimple): PATCH to really avoid copying empty classes (c++/43787)
- References: <4BE065DF.4070105@redhat.com> <201005052048.24785.ebotcazou@adacore.com>
On 05/05/2010 02:48 PM, Eric Botcazou wrote:
For this to work, it was necessary to fix the gimplifier to give the
langhook another crack at the assignment if gimplify_modify_expr_rhs
made any changes. To make this work that function needs to be fixed to
return GS_OK rather than GS_UNHANDLED if it made any changes, and
gimplify_expr also needs to loop again if the RHS changes.
This breaks variable-sized type return in Ada:
FAIL: gnat.dg/lto2.adb (test for excess errors)
FAIL: gnat.dg/varsize_temp.adb (test for excess errors)
FAIL: gnat.dg/specs/varsize_return.ads (test for excess errors)
Does this patch fix it for you?
commit 2a84737c32fcb04e7bd95073d495662b28bb4078
Author: Jason Merrill <jason@redhat.com>
Date: Wed May 5 17:57:12 2010 -0400
fix ada
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 3d12a75..e372803 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4293,7 +4293,10 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p,
if (TREE_CODE (TREE_OPERAND (*from_p, 0)) == CALL_EXPR)
{
*from_p = TREE_OPERAND (*from_p, 0);
- ret = GS_OK;
+ /* We don't change ret in this case because the
+ WITH_SIZE_EXPR might have been added in
+ gimplify_modify_expr, so returning GS_OK would lead to an
+ infinite loop. */
changed = true;
}
break;
@@ -6633,16 +6636,12 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
case MODIFY_EXPR:
case INIT_EXPR:
- {
- tree from = TREE_OPERAND (*expr_p, 1);
- ret = gimplify_modify_expr (expr_p, pre_p, post_p,
- fallback != fb_none);
- /* Don't let the end of loop logic change GS_OK into GS_ALL_DONE
- if the RHS has changed. */
- if (ret == GS_OK && *expr_p == save_expr
- && TREE_OPERAND (*expr_p, 1) != from)
- continue;
- }
+ ret = gimplify_modify_expr (expr_p, pre_p, post_p,
+ fallback != fb_none);
+ /* Don't let the end of loop logic change GS_OK to GS_ALL_DONE;
+ gimplify_modify_expr_rhs might have changed the RHS. */
+ if (ret == GS_OK && *expr_p)
+ continue;
break;
case TRUTH_ANDIF_EXPR: