aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2012-06-15 14:40:38 +0000
committerMichael Matz <matz@gcc.gnu.org>2012-06-15 14:40:38 +0000
commit6da8be895c345e90cec9a70fdeb38111fc48a880 (patch)
tree97534b2183367e8929d27bfc21c1ffdec14eb2a6
parentef5ad3b74564ef8039552d4d4e8098569fef3355 (diff)
downloadgcc-6da8be895c345e90cec9a70fdeb38111fc48a880.zip
gcc-6da8be895c345e90cec9a70fdeb38111fc48a880.tar.gz
gcc-6da8be895c345e90cec9a70fdeb38111fc48a880.tar.bz2
gimplify.c (gimplify_modify_expr): Fold generated statements.
* gimplify.c (gimplify_modify_expr): Fold generated statements. * gimple-fold.c (can_refer_decl_in_current_unit_p): Check flag_ltrans. testsuite/ * gcc.dg/debug/dwarf2/inline3.c: Adjust. * gcc.dg/tree-ssa/foldstring-1.c: Adjust. From-SVN: r188664
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimple-fold.c10
-rw-r--r--gcc/gimplify.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/foldstring-1.c6
6 files changed, 28 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e9f1890..7f21827 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-15 Michael Matz <matz@suse.de>
+
+ * gimplify.c (gimplify_modify_expr): Fold generated statements.
+ * gimple-fold.c (can_refer_decl_in_current_unit_p): Check flag_ltrans.
+
2012-06-15 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (set_and_canonicalize_value_range): Use canonical
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index b2bd337..08e9603 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -61,19 +61,21 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl)
struct cgraph_node *node;
symtab_node snode;
- /* We will later output the initializer, so we can reffer to it.
+ /* We will later output the initializer, so we can refer to it.
So we are concerned only when DECL comes from initializer of
external var. */
if (!from_decl
|| TREE_CODE (from_decl) != VAR_DECL
|| !DECL_EXTERNAL (from_decl)
- || (symtab_get_node (from_decl)->symbol.in_other_partition))
+ || (flag_ltrans
+ && symtab_get_node (from_decl)->symbol.in_other_partition))
return true;
- /* We are concerned ony about static/external vars and functions. */
+ /* We are concerned only about static/external vars and functions. */
if ((!TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
|| (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL))
return true;
- /* Weakrefs have somewhat confusing DECL_EXTERNAL flag set; they are always safe. */
+ /* Weakrefs have somewhat confusing DECL_EXTERNAL flag set; they
+ are always safe. */
if (DECL_EXTERNAL (decl)
&& lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
return true;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 633e326..c59e754 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4772,6 +4772,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
enum gimplify_status ret = GS_UNHANDLED;
gimple assign;
location_t loc = EXPR_LOCATION (*expr_p);
+ gimple_stmt_iterator gsi;
gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
|| TREE_CODE (*expr_p) == INIT_EXPR);
@@ -4912,8 +4913,6 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
gimple_set_location (assign, EXPR_LOCATION (*expr_p));
}
- gimplify_seq_add_stmt (pre_p, assign);
-
if (gimplify_ctxp->into_ssa && is_gimple_reg (*to_p))
{
/* If we've somehow already got an SSA_NAME on the LHS, then
@@ -4923,6 +4922,10 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
gimple_set_lhs (assign, *to_p);
}
+ gimplify_seq_add_stmt (pre_p, assign);
+ gsi = gsi_last (*pre_p);
+ fold_stmt (&gsi);
+
if (want_value)
{
*expr_p = TREE_THIS_VOLATILE (*to_p) ? *from_p : unshare_expr (*to_p);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ca264c3..44215ff 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-15 Michael Matz <matz@suse.de>
+
+ * gcc.dg/debug/dwarf2/inline3.c: Adjust.
+ * gcc.dg/tree-ssa/foldstring-1.c: Adjust.
+
2012-06-15 Ulrich Weigand <ulrich.weigand@linaro.org>
PR tree-optimization/53636
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c
index feafb33..d2d3e0f 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c
@@ -1,7 +1,7 @@
/* Verify that only one DW_AT_const_value is emitted for baz,
not for baz abstract DIE and again inside of
DW_TAG_inlined_subroutine. */
-/* { dg-options "-O2 -g -dA" } */
+/* { dg-options "-O2 -g -dA -fmerge-all-constants" } */
/* { dg-do compile } */
/* { dg-final { scan-assembler-times " DW_AT_const_value" 1 } } */
@@ -11,6 +11,9 @@ static inline long
foo (void)
{
const struct A baz = { .i = 2, .j = 21 };
+ /* We must make sure that baz isn't optimized away before inlining,
+ otherwise its initializer is also lost. */
+ const struct A *p = &baz;
asm volatile ("" : : : "memory");
return baz.i * baz.j;
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/foldstring-1.c b/gcc/testsuite/gcc.dg/tree-ssa/foldstring-1.c
index 3cfe44d..e738a44 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/foldstring-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/foldstring-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-fre1" } */
+/* { dg-options "-O1 -fdump-tree-gimple" } */
void
arf ()
@@ -7,5 +7,5 @@ arf ()
if (""[0] == 0)
blah ();
}
-/* { dg-final { scan-tree-dump-times "= 0;" 1 "fre1"} } */
-/* { dg-final { cleanup-tree-dump "fre1" } } */
+/* { dg-final { scan-tree-dump-times "= 0;" 1 "gimple"} } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */