This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING]: PATCH: PR tree-optimization/35494: [4.4 Regression]: Revision 132991 breaks C++ static member
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Richard Guenther" <richard dot guenther at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Mar 2008 09:17:06 -0700
- Subject: Re: [PING]: PATCH: PR tree-optimization/35494: [4.4 Regression]: Revision 132991 breaks C++ static member
- References: <20080310145545.GA9567@lucon.org>
On Mon, Mar 10, 2008 at 7:55 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> The current C++ compiler breaks C++ data member:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35494
>
> The current patch is at
>
> http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00572.html
>
> It passed all tests on Linux/x86 and Linux/Intel64 as well as
> 483.xalancbmk. OK to install?
>
Here is a smaller patch just for PR 35494. I am testing it on
Linux/x86 and Linux/Intel64 as well as 483.xalancbmk. OK to
install if all pases?
H.J.
gcc/
2008-03-08 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-07 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.
--- gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C.local 2008-03-08 18:11:53.000000000 -0800
+++ gcc/testsuite/g++.dg/tree-ssa/ssa-store-ccp-1.C 2008-03-08 18:11:53.000000000 -0800
@@ -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" } } */
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c.local 2008-03-08 18:11:53.000000000 -0800
+++ gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c 2008-03-08 18:11:53.000000000 -0800
@@ -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" } } */
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c.local 2008-03-08 18:11:53.000000000 -0800
+++ gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c 2008-03-08 18:11:53.000000000 -0800
@@ -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" } } */
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-4.c.local 2008-03-08 18:11:53.000000000 -0800
+++ gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-4.c 2008-03-08 18:11:53.000000000 -0800
@@ -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" } } */
--- gcc/tree-ssa-ccp.c.local 2008-03-07 09:02:37.000000000 -0800
+++ gcc/tree-ssa-ccp.c 2008-03-09 06:58:50.000000000 -0700
@@ -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