re PR tree-optimization/35494 (Revision 132991 breaks C++ static member)
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 10 Mar 2008 18:20:23 +0000 (18:20 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Mon, 10 Mar 2008 18:20:23 +0000 (11:20 -0700)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-4.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 21ec0bdf3b8f9855c1fad75995ab6cbcae07a074..9d3ba56ca53ae1701b4954796671fcaba08815f2 100644 (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
index 98466dc96778492a04c84b1dfb52309a2f9aefa3..693a2a1a7be22e7c9561987495eec234bbc56f78 100644 (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.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C b/gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C
new file mode 100644 (file)
index 0000000..06e9b1e
--- /dev/null
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c
new file mode 100644 (file)
index 0000000..be37a21
--- /dev/null
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c
new file mode 100644 (file)
index 0000000..2f028a2
--- /dev/null
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-4.c
new file mode 100644 (file)
index 0000000..cbf8bab
--- /dev/null
@@ -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" } } */
index b9211a5df9c5d3d9058711988a56910da550f33b..7cefbf838933e67639407a12bef40907e9c2f33e 100644 (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