From 76a7d3ca5162b468a9d44ecbc3efcd2ecfd15f9a Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Tue, 11 Mar 2008 21:08:00 +0000 Subject: [PATCH] re PR tree-optimization/35403 (ipa-reference.c does not change a default initialized static variable to be readonly) 2008-03-11 Andrew Pinski * ipa-reference.c (static_execute): Remove module_statics_const and associated setting code. 2008-03-11 Andrew Pinski PR tree-opt/35403 * gcc.dg/tree-ssa/ipa-reference-1.c: New testcase. From-SVN: r133119 --- gcc/ChangeLog | 5 +++++ gcc/ipa-reference.c | 10 ---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/ipa-reference-1.c | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ipa-reference-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ccd9abee4ce..510ccb05a32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-03-11 Andrew Pinski + + * ipa-reference.c (static_execute): Remove module_statics_const and + associated setting code. + 2008-03-11 Uros Bizjak PR target/35540 diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 1a962c52cdb..87d8c2fa144 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -949,7 +949,6 @@ static_execute (void) unsigned int index; bitmap_iterator bi; bitmap module_statics_readonly = BITMAP_ALLOC (&ipa_obstack); - bitmap module_statics_const = BITMAP_ALLOC (&ipa_obstack); bitmap bm_temp = BITMAP_ALLOC (&ipa_obstack); EXECUTE_IF_SET_IN_BITMAP (module_statics_escape, 0, index, bi) @@ -999,14 +998,6 @@ static_execute (void) fprintf (dump_file, "read-only var %s\n", get_static_name (index)); } - if (DECL_INITIAL (var) - && is_gimple_min_invariant (DECL_INITIAL (var))) - { - bitmap_set_bit (module_statics_const, index); - if (dump_file) - fprintf (dump_file, "read-only constant %s\n", - get_static_name (index)); - } } BITMAP_FREE(module_statics_escape); @@ -1036,7 +1027,6 @@ static_execute (void) } BITMAP_FREE(module_statics_readonly); - BITMAP_FREE(module_statics_const); BITMAP_FREE(bm_temp); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1fd06c444a9..52a96c33822 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-11 Andrew Pinski + + PR tree-opt/35403 + * gcc.dg/tree-ssa/ipa-reference-1.c: New testcase. + 2008-03-11 Uros Bizjak PR target/35540 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ipa-reference-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ipa-reference-1.c new file mode 100644 index 00000000000..c15a8b60991 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ipa-reference-1.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +static int conststaticvariable; + +int f(void) +{ + return conststaticvariable; +} + +/* There should be no reference to conststaticvariable as we should have + inlined the 0 as IPA reference should have marked the variable as a const + as it is not set in the IR. */ +/* { dg-final { scan-tree-dump-times "conststaticvariable" 0 "optimized"} } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ -- 2.30.2