diff options
author | Jason Merrill <jason@redhat.com> | 2010-08-19 13:00:51 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-08-19 13:00:51 -0400 |
commit | ce3beba3df013a2ebffbde6bf691f396dd968f61 (patch) | |
tree | 07707b32a91d6054569c09547fee746ce8b65038 /gcc | |
parent | 2c5df20f2ee3af837efdcf9a384a5fb600791050 (diff) | |
download | gcc-ce3beba3df013a2ebffbde6bf691f396dd968f61.zip gcc-ce3beba3df013a2ebffbde6bf691f396dd968f61.tar.gz gcc-ce3beba3df013a2ebffbde6bf691f396dd968f61.tar.bz2 |
re PR middle-end/45307 (Stores expanding to no RTL not removed by tree optimizers, Empty ctors/dtors not eliminated)
PR c++/45307
* gimplify.c (gimplify_init_constructor): Just return GS_UNHANDLED
if ctor is empty.
(gimplify_modify_expr_rhs): Adjust.
From-SVN: r163380
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 15 | ||||
-rw-r--r-- | gcc/gimplify.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-ssa/empty-2.C | 8 |
6 files changed, 34 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7588c98e..f7461ba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-08-19 Jason Merrill <jason@redhat.com> + + PR c++/45307 + * gimplify.c (gimplify_init_constructor): Just return GS_UNHANDLED + if ctor is empty. + (gimplify_modify_expr_rhs): Adjust. + 2010-08-19 Nathan Froyd <froydnj@codesourcery.com> * cfgloop.c (get_loop_body_in_bfs_order): Avoid redundant call to diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d93fd4a..7667bb6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-08-19 Jason Merrill <jason@redhat.com> + PR c++/45307 + * cp-gimplify.c (cp_gimplify_expr): Also remove assignment + of empty class CONSTRUCTOR. + * except.c (pending_noexcept, pending_noexcept_checks): New. (perform_deferred_noexcept_checks): New. (maybe_noexcept_warning): Split from... diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index abd5bf3..e5a7f26 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -575,15 +575,18 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) TREE_OPERAND (*expr_p, 1) = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (op0), op1); - else if ((is_gimple_lvalue (op1) || INDIRECT_REF_P (op1)) - && !(TREE_CODE (op1) == CALL_EXPR - && CALL_EXPR_RETURN_SLOT_OPT (op1)) + else if ((is_gimple_lvalue (op1) || INDIRECT_REF_P (op1) + || (TREE_CODE (op1) == CONSTRUCTOR + && CONSTRUCTOR_NELTS (op1) == 0) + || (TREE_CODE (op1) == CALL_EXPR + && !CALL_EXPR_RETURN_SLOT_OPT (op1))) && is_really_empty_class (TREE_TYPE (op0))) { /* Remove any copies of empty classes. We check that the RHS - has a simple form so that TARGET_EXPRs and CONSTRUCTORs get - reduced properly, and we leave the return slot optimization - alone because it isn't a copy. + has a simple form so that TARGET_EXPRs and non-empty + CONSTRUCTORs get reduced properly, and we leave the return + slot optimization alone because it isn't a copy (FIXME so it + shouldn't be represented as one). Also drop volatile variables on the RHS to avoid infinite recursion from gimplify_expr trying to load the value. */ diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8b97ee3..7e33666 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4237,6 +4237,10 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, break; case CONSTRUCTOR: + /* If we already made some changes, let the front end have a + crack at this before we break it down. */ + if (ret != GS_UNHANDLED) + break; /* If we're initializing from a CONSTRUCTOR, break this into individual MODIFY_EXPRs. */ return gimplify_init_constructor (expr_p, pre_p, post_p, want_value, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 304a8e8..289a124 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2010-08-19 Jason Merrill <jason@redhat.com> + * g++.dg/tree-ssa/empty-2.C: New. + * g++.dg/cpp0x/noexcept09.C: New. 2010-08-19 Daniel Kraft <d@domob.eu> diff --git a/gcc/testsuite/g++.dg/tree-ssa/empty-2.C b/gcc/testsuite/g++.dg/tree-ssa/empty-2.C new file mode 100644 index 0000000..728678a --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/empty-2.C @@ -0,0 +1,8 @@ +// PR c++/45307 +// { dg-options -fdump-tree-gimple } + +struct fallible_t { }; +const fallible_t fallible = fallible_t(); + +// { dg-final { scan-tree-dump-not "fallible" "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } } |