summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-05 15:10:26 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-05 15:10:26 +0000
commitcbabc8ebcf815ed8bc322d48595c9b1f74dfe48c (patch)
treeee21d182e30d8ac396d80fa9bce2b45bf034ef8e /gcc
parent9ea022ce271af3940dd9a9775e8b296a699e3d38 (diff)
downloadgcc-cbabc8ebcf815ed8bc322d48595c9b1f74dfe48c.tar.gz
PR middle-end/51761
* gimple.h (struct gimplify_ctx): Add in_cleanup_point_expr field. * gimplify.c (gimplify_cleanup_point_expr): Save and set in_cleanup_point_expr before gimplify_stmt call and restore it afterwards. (gimplify_target_expr): Don't add {CLOBBER} cleanup if in_cleanup_point_expr is false. * gcc.c-torture/compile/pr51761.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182914 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/gimple.h3
-rw-r--r--gcc/gimplify.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr51761.c10
5 files changed, 35 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c28e9463dde..7deeca506dc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2012-01-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/51761
+ * gimple.h (struct gimplify_ctx): Add in_cleanup_point_expr
+ field.
+ * gimplify.c (gimplify_cleanup_point_expr): Save and set
+ in_cleanup_point_expr before gimplify_stmt call and restore it
+ afterwards.
+ (gimplify_target_expr): Don't add {CLOBBER} cleanup if
+ in_cleanup_point_expr is false.
+
2012-01-05 Richard Guenther <rguenther@suse.de>
PR middle-end/51764
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 9ac8f26c55f..484d1a0b407 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1,6 +1,6 @@
/* Gimple IR definitions.
- Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldyh@redhat.com>
This file is part of GCC.
@@ -1092,6 +1092,7 @@ struct gimplify_ctx
bool save_stack;
bool into_ssa;
bool allow_rhs_cond_expr;
+ bool in_cleanup_point_expr;
};
extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *,
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 14d627e7254..5f2cbf3c769 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1,7 +1,7 @@
/* Tree lowering pass. This pass converts the GENERIC functions-as-trees
tree representation into the GIMPLE form.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+ 2012 Free Software Foundation, Inc.
Major work done by Sebastian Pop <s.pop@laposte.net>,
Diego Novillo <dnovillo@redhat.com> and Jason Merrill <jason@redhat.com>.
@@ -5226,13 +5226,16 @@ gimplify_cleanup_point_expr (tree *expr_p, gimple_seq *pre_p)
any cleanups collected outside the CLEANUP_POINT_EXPR. */
int old_conds = gimplify_ctxp->conditions;
gimple_seq old_cleanups = gimplify_ctxp->conditional_cleanups;
+ bool old_in_cleanup_point_expr = gimplify_ctxp->in_cleanup_point_expr;
gimplify_ctxp->conditions = 0;
gimplify_ctxp->conditional_cleanups = NULL;
+ gimplify_ctxp->in_cleanup_point_expr = true;
gimplify_stmt (&TREE_OPERAND (*expr_p, 0), &body_sequence);
gimplify_ctxp->conditions = old_conds;
gimplify_ctxp->conditional_cleanups = old_cleanups;
+ gimplify_ctxp->in_cleanup_point_expr = old_in_cleanup_point_expr;
for (iter = gsi_start (body_sequence); !gsi_end_p (iter); )
{
@@ -5408,7 +5411,8 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
/* Add a clobber for the temporary going out of scope, like
gimplify_bind_expr. */
- if (needs_to_live_in_memory (temp))
+ if (gimplify_ctxp->in_cleanup_point_expr
+ && needs_to_live_in_memory (temp))
{
tree clobber = build_constructor (TREE_TYPE (temp), NULL);
TREE_THIS_VOLATILE (clobber) = true;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1064393e138..725c79cb180 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/51761
+ * gcc.c-torture/compile/pr51761.c: New test.
+
2012-01-05 Richard Guenther <rguenther@suse.de>
PR tree-optimization/51760
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr51761.c b/gcc/testsuite/gcc.c-torture/compile/pr51761.c
new file mode 100644
index 00000000000..68911c84ce1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr51761.c
@@ -0,0 +1,10 @@
+/* PR middle-end/51761 */
+
+struct S { unsigned int len; };
+struct S foo (struct S);
+
+struct S
+bar (struct S x)
+{
+ return ({ struct S a = x; foo (a); });
+}