re PR tree-optimization/35494 (Revision 132991 breaks C++ static member)

gcc/

2008-03-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR tree-optimization/35494
	* tree-ssa-ccp.c (get_symbol_constant_value): Check if value
	may be overriden at link and run time.

gcc/testsuite/

2008-03-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR tree-optimization/35494
	* g++.dg/tree-ssa/ssa-store-ccp-1.C: New.
	* gcc.dg/tree-ssa/ssa-store-ccp-2.c: Likewise.
	* gcc.dg/tree-ssa/ssa-store-ccp-3.c: Likewise.
	* gcc.dg/tree-ssa/ssa-store-ccp-4.c: Likewise.

From-SVN: r133082
This commit is contained in:
H.J. Lu 2008-03-10 18:20:23 +00:00 committed by H.J. Lu
parent 3ba404dfe1
commit 725c2d321c
7 changed files with 80 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2008-03-10 H.J. Lu <hongjiu.lu@intel.com>
PR tree-optimization/35494
* tree-ssa-ccp.c (get_symbol_constant_value): Check if value
may be overriden at link and run time.
2008-03-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/34677

View File

@ -1,19 +1,14 @@
2008-03-10 H.J. Lu <hongjiu.lu@intel.com>
PR tree-optimization/35494
* g++.dg/tree-ssa/ssa-store-ccp-1.C: New.
* gcc.dg/tree-ssa/ssa-store-ccp-2.c: Likewise.
* gcc.dg/tree-ssa/ssa-store-ccp-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-store-ccp-4.c: Likewise.
2008-03-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/34677
* tree-ssa-pre.c (modify_expr_node_pool): Remove.
(poolify_tree): Likewise.
(modify_expr_template): Likewise.
(poolify_modify_stmt): Likewise.
(insert_fake_stores): Handle all component-ref style stores
in addition to INDIRECT_REF. Also handle complex types.
Do not poolify the inserted load.
(realify_fake_stores): Do not rebuild the tree but only
make it a SSA_NAME copy.
(init_pre): Remove initialzation of modify_expr_template.
Do not allocate modify_expr_node_pool.
(fini_pre): Do not free modify_expr_node_pool.
* gcc.dg/tree-ssa/loadpre23.c: New testcase.
* gcc.dg/tree-ssa/loadpre24.c: Likewise.
* gcc.dg/tree-ssa/loadpre25.c: Likewise.

View File

@ -0,0 +1,19 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
class bar
{
public:
static const int conststaticvariable;
};
int f(void)
{
return bar::conststaticvariable;
}
/* There should be a reference to conststaticvariable since it may
be overriden at link time. */
/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -0,0 +1,14 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
const int conststaticvariable;
int f(void)
{
return conststaticvariable;
}
/* There should be a reference to conststaticvariable since it may
may be overriden at link time. */
/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -0,0 +1,14 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-common -fdump-tree-optimized" } */
const int conststaticvariable;
int f(void)
{
return conststaticvariable;
}
/* There should be no reference to conststaticvariable as we should have
inlined the 0. */
/* { dg-final { scan-tree-dump-times "conststaticvariable" 0 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-require-effective-target fpic } */
/* { dg-options "-O2 -fno-common -fpic -fdump-tree-optimized" } */
const int conststaticvariable;
int f(void)
{
return conststaticvariable;
}
/* There should be a reference to conststaticvariable since it may
may be overriden at run time. */
/* { dg-final { scan-tree-dump-times "conststaticvariable" 1 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -300,7 +300,10 @@ get_symbol_constant_value (tree sym)
{
if (TREE_STATIC (sym)
&& TREE_READONLY (sym)
&& !MTAG_P (sym))
&& !MTAG_P (sym)
/* Check if a read-only definition may be overridden at
link and run time. */
&& targetm.binds_local_p (sym))
{
tree val = DECL_INITIAL (sym);
if (val