OSDN Git Service

gcc/
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Mar 2008 18:20:23 +0000 (18:20 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Mar 2008 18:20:23 +0000 (18:20 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133082 138bc75d-0d04-0410-961f-82ee72b054a4

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 21ec0bd..9d3ba56 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 98466dc..693a2a1 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 b9211a5..7cefbf8 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