public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36185]  New: wrong code with  -O2 -fgcse-sm
@ 2008-05-09  8:41 wouter dot vermaelen at scarlet dot be
  2008-05-09  9:22 ` [Bug rtl-optimization/36185] [4.4 Regression] " rguenth at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2008-05-09  8:41 UTC (permalink / raw)
  To: gcc-bugs

> cat -n bug.cc
     1  struct Base {
     2          virtual ~Base() {}
     3          virtual void f() = 0;
     4  };
     5  struct Derived : Base {
     6          Derived();
     7          virtual void f() {}
     8  };
     9  struct Foo {
    10          Foo(Base&);
    11  };
    12
    13  Derived::Derived() {
    14          Foo foo(*this);
    15  }
    16  Foo::Foo(Base& base) {
    17          base.f();
    18  }
    19  int main() {
    20          Derived d;
    21  }

> g++ -g -O2 -fgcse-sm bug.cc
> ./a.out
Segmentation fault (core dumped)

#0  0x0000000000000000 in ?? ()
#1  0x0000000000400775 in Derived (this=0x7fff2fc93390) at bug.cc:14
#2  0x00000000004007ec in main () at bug.cc:20


I'm using gcc revision 135109 on linux x86_64.


-- 
           Summary: wrong code with  -O2 -fgcse-sm
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wouter dot vermaelen at scarlet dot be


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/36185] [4.4 Regression] wrong code with  -O2 -fgcse-sm
  2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
@ 2008-05-09  9:22 ` rguenth at gcc dot gnu dot org
  2008-05-09 13:02 ` [Bug c++/36185] " wouter dot vermaelen at scarlet dot be
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-05-09  9:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-05-09 09:21 -------
Confirmed.  We move parameter initialization after the call...

  this->D.2090._vptr.Base = &_ZTV7Derived[2];
  __comp_ctor  (&foo, &this->D.2090);

@@ -59,11 +59,11 @@
        movq    %rbx, %rsi
        subq    $16, %rsp
 .LCFI1:
-       movq    $_ZTV7Derived+16, (%rdi)
        leaq    15(%rsp), %rdi
 .LEHB0:
        call    _ZN3FooC1ER4Base
 .LEHE0:
+       movq    $_ZTV7Derived+16, (%rbx)
        addq    $16, %rsp
        popq    %rbx
        ret


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |rtl-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2008-05-09 09:21:23
               date|                            |
            Summary|wrong code with  -O2 -fgcse-|[4.4 Regression] wrong code
                   |sm                          |with  -O2 -fgcse-sm
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/36185] [4.4 Regression] wrong code with  -O2 -fgcse-sm
  2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
  2008-05-09  9:22 ` [Bug rtl-optimization/36185] [4.4 Regression] " rguenth at gcc dot gnu dot org
@ 2008-05-09 13:02 ` wouter dot vermaelen at scarlet dot be
  2008-05-09 15:05 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2008-05-09 13:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from wouter dot vermaelen at scarlet dot be  2008-05-09 13:02 -------
This bug seems to be introduced in (or triggered by) revision 135053:
  trunk@135049 -> still ok
  trunk@135053 -> generates wrong code 


-- 

wouter dot vermaelen at scarlet dot be changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|rtl-optimization            |c++


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/36185] [4.4 Regression] wrong code with  -O2 -fgcse-sm
  2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
  2008-05-09  9:22 ` [Bug rtl-optimization/36185] [4.4 Regression] " rguenth at gcc dot gnu dot org
  2008-05-09 13:02 ` [Bug c++/36185] " wouter dot vermaelen at scarlet dot be
@ 2008-05-09 15:05 ` rguenth at gcc dot gnu dot org
  2008-05-10 20:29 ` zadeck at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-05-09 15:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-05-09 15:04 -------
Kenny, that's your PURE/CONST patch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zadeck at naturalbridge dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/36185] [4.4 Regression] wrong code with  -O2 -fgcse-sm
  2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
                   ` (2 preceding siblings ...)
  2008-05-09 15:05 ` rguenth at gcc dot gnu dot org
@ 2008-05-10 20:29 ` zadeck at gcc dot gnu dot org
  2008-05-10 20:30 ` zadeck at naturalbridge dot com
  2008-05-10 21:28 ` zadeck at naturalbridge dot com
  5 siblings, 0 replies; 7+ messages in thread
From: zadeck at gcc dot gnu dot org @ 2008-05-10 20:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from zadeck at gcc dot gnu dot org  2008-05-10 20:29 -------
Subject: Bug 36185

Author: zadeck
Date: Sat May 10 20:28:19 2008
New Revision: 135159

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135159
Log:
2008-05-10  Kenneth Zadeck  <zadeck@naturalbridge.com>

    * gcse.c (store_killed_in_insn): Negated call to RTL_CONST_CALL_P.

2008-05-10  Kenneth Zadeck  <zadeck@naturalbridge.com>

        PR rtl-optimization/36185
        * g++.dg/opt/pr36185.C


Added:
    trunk/gcc/testsuite/g++.dg/opt/pr36185.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gcse.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/36185] [4.4 Regression] wrong code with  -O2 -fgcse-sm
  2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
                   ` (3 preceding siblings ...)
  2008-05-10 20:29 ` zadeck at gcc dot gnu dot org
@ 2008-05-10 20:30 ` zadeck at naturalbridge dot com
  2008-05-10 21:28 ` zadeck at naturalbridge dot com
  5 siblings, 0 replies; 7+ messages in thread
From: zadeck at naturalbridge dot com @ 2008-05-10 20:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from zadeck at naturalbridge dot com  2008-05-10 20:29 -------
Subject: Re:  [4.4 Regression] wrong code with  -O2 -fgcse-sm

rguenth at gcc dot gnu dot org wrote:
> ------- Comment #3 from rguenth at gcc dot gnu dot org  2008-05-09 15:04 -------
> Kenny, that's your PURE/CONST patch.
>
>
>   
I am checking this in as obvious because given the frag from the first 
pure const patch, this is an obvious fix.   I left out the '!' when I 
converted this conditional.    (I also discussed this with Iant before i 
tested the fix).

The patch was tested on x86-64.

committed as revision 135185.

Kenny

@@ -5987,7 +5987,7 @@ store_killed_in_insn (const_rtx x, const
     {
       /* A normal or pure call might read from pattern,
      but a const call will not.  */
-      if (! CONST_OR_PURE_CALL_P (insn) || pure_call_p (insn))
+      if (RTL_CONST_CALL_P (insn))
     return true;

       /* But even a const call reads its parameters.  Check whether the



2008-05-10  Kenneth Zadeck  <zadeck@naturalbridge.com>

    * gcse.c (store_killed_in_insn): Negated call to RTL_CONST_CALL_P.

2008-05-10  Kenneth Zadeck  <zadeck@naturalbridge.com>

    PR rtl-optimization/36185
    * g++.dg/opt/pr36185.C

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 135153)
+++ ChangeLog   (working copy)
@@ -1,3 +1,7 @@
+2008-05-10  Kenneth Zadeck  <zadeck@naturalbridge.com>
+
+       * gcse.c (store_killed_in_insn): Negated call to RTL_CONST_CALL_P.
+               
 2008-05-10  H.J. Lu  <hongjiu.lu@intel.com>

        * config/i386/i386.c (bdesc_ptest): Removed.
Index: testsuite/g++.dg/opt/pr36185.C
===================================================================
--- testsuite/g++.dg/opt/pr36185.C      (revision 0)
+++ testsuite/g++.dg/opt/pr36185.C      (revision 0)
@@ -0,0 +1,24 @@
+// PR rtl-optimization/36185
+// { dg-do run }
+// { dg-options "-O2 -fgcse-sm" }
+
+struct Base {
+        virtual ~Base() {}
+        virtual void f() = 0;
+};
+struct Derived : Base {
+        Derived();
+        virtual void f() {}
+};
+struct Foo {
+        Foo(Base&);
+};
+Derived::Derived() {
+        Foo foo(*this);
+}
+Foo::Foo(Base& base) {
+        base.f();
+}
+int main() {
+        Derived d;
+}
Index: gcse.c
===================================================================
--- gcse.c      (revision 135153)
+++ gcse.c      (working copy)
@@ -5987,7 +5987,7 @@ store_killed_in_insn (const_rtx x, const
     {
       /* A normal or pure call might read from pattern,
         but a const call will not.  */
-      if (RTL_CONST_CALL_P (insn))
+      if (!RTL_CONST_CALL_P (insn))
        return true;

       /* But even a const call reads its parameters.  Check whether the


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/36185] [4.4 Regression] wrong code with  -O2 -fgcse-sm
  2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
                   ` (4 preceding siblings ...)
  2008-05-10 20:30 ` zadeck at naturalbridge dot com
@ 2008-05-10 21:28 ` zadeck at naturalbridge dot com
  5 siblings, 0 replies; 7+ messages in thread
From: zadeck at naturalbridge dot com @ 2008-05-10 21:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from zadeck at naturalbridge dot com  2008-05-10 21:27 -------
fixed with commit of patch.


-- 

zadeck at naturalbridge dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36185


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-05-10 21:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-09  8:41 [Bug c++/36185] New: wrong code with -O2 -fgcse-sm wouter dot vermaelen at scarlet dot be
2008-05-09  9:22 ` [Bug rtl-optimization/36185] [4.4 Regression] " rguenth at gcc dot gnu dot org
2008-05-09 13:02 ` [Bug c++/36185] " wouter dot vermaelen at scarlet dot be
2008-05-09 15:05 ` rguenth at gcc dot gnu dot org
2008-05-10 20:29 ` zadeck at gcc dot gnu dot org
2008-05-10 20:30 ` zadeck at naturalbridge dot com
2008-05-10 21:28 ` zadeck at naturalbridge dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).