public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33572]  New: wrong code with -O
@ 2007-09-27 16:03 wouter dot vermaelen at scarlet dot be
  2007-09-27 16:37 ` [Bug c++/33572] " pcarlini at suse dot de
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2007-09-27 16:03 UTC (permalink / raw)
  To: gcc-bugs

> cat bug.cc
#include <vector>
#include <memory>

struct Foo { virtual void f() {} };

int main(int argc, char**)
{
        std::auto_ptr<Foo> foo;
        if (argc) {
                foo.reset(new Foo());
        } else {
                std::vector<int> v;
        }
        Foo* p = foo.release();
        p->f();
}

> g++ -O bug.cc
> a.out
Segmentation fault (core dumped)

I'm using SVN revision 128838 on linux-x86_64.
Without -O or with g++ version 4.2.1 this program works correctly.


-- 
           Summary: wrong code with -O
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: major
          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=33572


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

* [Bug c++/33572] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
@ 2007-09-27 16:37 ` pcarlini at suse dot de
  2007-09-27 20:21 ` belyshev at depni dot sinp dot msu dot ru
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: pcarlini at suse dot de @ 2007-09-27 16:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pcarlini at suse dot de  2007-09-27 16:36 -------
I can't reproduce...


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code with -O          |wrong code with -O


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


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

* [Bug c++/33572] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
  2007-09-27 16:37 ` [Bug c++/33572] " pcarlini at suse dot de
@ 2007-09-27 20:21 ` belyshev at depni dot sinp dot msu dot ru
  2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2007-09-27 20:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from belyshev at depni dot sinp dot msu dot ru  2007-09-27 20:20 -------
Could you please attach preprocessed source (.ii file ) and assembly output
(.s) (use -save-temps option to generate them)


-- 

belyshev at depni dot sinp dot msu dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |belyshev at depni dot sinp
                   |                            |dot msu dot ru
           Severity|major                       |normal
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/33572] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
  2007-09-27 16:37 ` [Bug c++/33572] " pcarlini at suse dot de
  2007-09-27 20:21 ` belyshev at depni dot sinp dot msu dot ru
@ 2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
  2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2007-09-27 20:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from wouter dot vermaelen at scarlet dot be  2007-09-27 20:31 -------
Created an attachment (id=14258)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14258&action=view)
assembly output (for reduced bug.ii)


-- 


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


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

* [Bug c++/33572] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (2 preceding siblings ...)
  2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
@ 2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
  2007-09-27 21:03 ` [Bug tree-optimization/33572] [4.3 Regression] " rguenth at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: wouter dot vermaelen at scarlet dot be @ 2007-09-27 20:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from wouter dot vermaelen at scarlet dot be  2007-09-27 20:30 -------
Created an attachment (id=14257)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14257&action=view)
preprocessed source (reduced)


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (3 preceding siblings ...)
  2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
@ 2007-09-27 21:03 ` rguenth at gcc dot gnu dot org
  2007-09-27 21:19 ` pcarlini at suse dot de
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-27 21:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2007-09-27 21:03 -------
Confirmed.  The reduced testcase gets optimized to

<bb 3>:
  D.2145 = operator new (8);

<bb 4>:
  ((struct Foo *) D.2145)->_vptr.Foo = &_ZTV3Foo[2];

<bb 5>:
  D.2147 ={v} 0B->_vptr.Foo;
  OBJ_TYPE_REF(*D.2147;0B->0) (0B);

where dereferencing NULL obviously is bogus.  After 038t.sdse2 everything
looks ok:

<bb 4>:
  D.2124_3 = (struct Foo *) D.2145_2;
  D.2124_3->_vptr.Foo ={v} &_ZTV3Foo[2];
  goto <bb 6>;

<bb 5>:
  deallocate (&v, 0B);

<bb 6>:
  # foo$ptr_16 = PHI <foo$ptr_18(ab)(5), D.2124_3(4)>
  foo$ptr_19(ab) = 0B;
  D.2147_6 = foo$ptr_16->_vptr.Foo;
  D.2148_7 = *D.2147_6;

but after apply inline it's wrong!?

<bb 3>:
  D.2145_2 = operator new (8);

<bb 4>:
  D.2124_3 = (struct Foo *) D.2145_2;
  D.2124_3->_vptr.Foo ={v} &_ZTV3Foo[2];

<bb 5>:
  # foo$ptr_16 = PHI <foo$ptr_18(ab)(2), D.2124_3(4)>
  foo$ptr_19(ab) = 0B;
  D.2147_6 = foo$ptr_19(ab)->_vptr.Foo;
  D.2148_7 = *D.2147_6;
  OBJ_TYPE_REF(D.2148_7;foo$ptr_19(ab)->0) (foo$ptr_19(ab));
  goto <bb 7>;


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|WAITING                     |NEW
          Component|c++                         |tree-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2007-09-27 21:03:18
               date|                            |
            Summary|wrong code with -O          |[4.3 Regression] wrong code
                   |                            |with -O
   Target Milestone|---                         |4.3.0


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (4 preceding siblings ...)
  2007-09-27 21:03 ` [Bug tree-optimization/33572] [4.3 Regression] " rguenth at gcc dot gnu dot org
@ 2007-09-27 21:19 ` pcarlini at suse dot de
  2007-09-28 12:28 ` rguenth at gcc dot gnu dot org
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: pcarlini at suse dot de @ 2007-09-27 21:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2007-09-27 21:19 -------
I can see now from the reduced testcase that the library uses mt_alloc, not the
default allocator. Next time, just say it... ;)


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (5 preceding siblings ...)
  2007-09-27 21:19 ` pcarlini at suse dot de
@ 2007-09-28 12:28 ` rguenth at gcc dot gnu dot org
  2007-09-28 12:59 ` rguenth at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-28 12:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2007-09-28 12:28 -------
After inlining deallocate into main we end up with:

int main(int, char**) (argc, D.2111)
{
  static struct __pool pool;
  static struct __pool pool;
  int * p;
  struct Foo * foo$ptr;
  struct Foo * D.2185;
  struct Foo * D.2182;
  int save_filt.2;
  void * save_eptr.1;
  struct vector v;
  int (*__vtbl_ptr_type) (void) D.2148;
  int (*__vtbl_ptr_type) (void) * D.2147;
  void * D.2145;
  struct Foo * D.2124;

<bb 2>:
  foo$ptr_18(ab) = 0B;
  if (argc_1(D) != 0)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 3>:
  D.2145_2 = operator new (8);

<bb 4>:
  D.2124_3 = (struct Foo *) D.2145_2;
  D.2124_3->_vptr.Foo ={v} &_ZTV3Foo[2];
  goto <bb 10>;

<bb 5>:

<bb 6>:
  if (0)
    goto <bb 7>;
  else
    goto <bb 8>;

<bb 7>:
  _M_reclaim_block (&pool, 0B, 0);

<bb 8>:

<bb 9>:

<bb 10>:
  # foo$ptr_16 = PHI <foo$ptr_18(ab)(9), D.2124_3(4)>
  foo$ptr_19(ab) = 0B;
  D.2147_6 = foo$ptr_16->_vptr.Foo;
  D.2148_7 = *D.2147_6;
  OBJ_TYPE_REF(D.2148_7;foo$ptr_16->0) (foo$ptr_16);
  goto <bb 12>;

  # foo$ptr_17(ab) = PHI <foo$ptr_18(ab)(3), (7), foo$ptr_19(ab)(10)>
<L3>:;
  save_filt.2_10 = <<<filter object>>>;
  save_eptr.1_11 = <<<exception object>>>;
  D.2182_13 = foo$ptr_17(ab);
  operator delete (D.2182_13);
  <<<exception object>>> = save_eptr.1_11;
  <<<filter object>>> = save_filt.2_10;
  resx 1;

<bb 12>:
  D.2185_14 = foo$ptr_19(ab);
  operator delete (D.2185_14);
  return 0;

}

after cleanup_cfg it still looks sane:

int main(int, char**) (argc, D.2111)
{
  static struct __pool pool;
  static struct __pool pool;
  int * p;
  struct Foo * foo$ptr;
  struct Foo * D.2185;
  struct Foo * D.2182;
  int save_filt.2;
  void * save_eptr.1;
  struct vector v;
  int (*__vtbl_ptr_type) (void) D.2148;
  int (*__vtbl_ptr_type) (void) * D.2147;
  void * D.2145;
  struct Foo * D.2124;

<bb 2>:
  foo$ptr_18(ab) = 0B;
  if (argc_1(D) != 0)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 3>:
  D.2145_2 = operator new (8);

<bb 4>:
  D.2124_3 = (struct Foo *) D.2145_2;
  D.2124_3->_vptr.Foo ={v} &_ZTV3Foo[2];

<bb 5>:
  # foo$ptr_16 = PHI <foo$ptr_18(ab)(2), D.2124_3(4)>
  foo$ptr_19(ab) = 0B;
  D.2147_6 = foo$ptr_16->_vptr.Foo;
  D.2148_7 = *D.2147_6;
  OBJ_TYPE_REF(D.2148_7;foo$ptr_16->0) (foo$ptr_16);
  goto <bb 7>;

  # foo$ptr_17(ab) = PHI <foo$ptr_18(ab)(3), foo$ptr_19(ab)(5)>
<L3>:;
  save_filt.2_10 = <<<filter object>>>;
  save_eptr.1_11 = <<<exception object>>>;
  D.2182_13 = foo$ptr_17(ab);
  operator delete (D.2182_13);
  <<<exception object>>> = save_eptr.1_11;
  <<<filter object>>> = save_filt.2_10;
  resx 1;

<bb 7>:
  D.2185_14 = foo$ptr_19(ab);
  operator delete (D.2185_14);
  return 0;

}

the update_ssa (2048) call makes a mess out of it:

int main(int, char**) (argc, D.2111)
{
  static struct __pool pool;
  static struct __pool pool;
  int * p;
  struct Foo * foo$ptr;
  struct Foo * D.2185;
  struct Foo * D.2182;
  int save_filt.2;
  void * save_eptr.1;
  struct vector v;
  int (*__vtbl_ptr_type) (void) D.2148;
  int (*__vtbl_ptr_type) (void) * D.2147;
  void * D.2145;
  struct Foo * D.2124;

<bb 2>:
  foo$ptr_18(ab) = 0B;
  if (argc_1(D) != 0)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 3>:
  D.2145_2 = operator new (8);

<bb 4>:
  D.2124_3 = (struct Foo *) D.2145_2;
  D.2124_3->_vptr.Foo ={v} &_ZTV3Foo[2];

<bb 5>:
  # foo$ptr_16 = PHI <foo$ptr_18(ab)(2), D.2124_3(4)>
  foo$ptr_19(ab) = 0B;
  D.2147_6 = foo$ptr_19(ab)->_vptr.Foo;
  D.2148_7 = *D.2147_6;
  OBJ_TYPE_REF(D.2148_7;foo$ptr_19(ab)->0) (foo$ptr_19(ab));
  goto <bb 7>;

  # foo$ptr_17(ab) = PHI <foo$ptr_18(ab)(3), foo$ptr_19(ab)(5)>
<L3>:;
  save_filt.2_10 = <<<filter object>>>;
  save_eptr.1_11 = <<<exception object>>>;
  D.2182_13 = foo$ptr_17(ab);
  operator delete (D.2182_13);
  <<<exception object>>> = save_eptr.1_11;
  <<<filter object>>> = save_filt.2_10;
  resx 1;

<bb 7>:
  D.2185_14 = foo$ptr_19(ab);
  operator delete (D.2185_14);
  return 0;

}


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (6 preceding siblings ...)
  2007-09-28 12:28 ` rguenth at gcc dot gnu dot org
@ 2007-09-28 12:59 ` rguenth at gcc dot gnu dot org
  2007-09-30 12:41 ` rguenth at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-28 12:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2007-09-28 12:59 -------
Honza, as only foo$ptr is marked for renaming and that from
update_ssa_across_eh_edges (), maybe this is a latent problem with inlining
and EH info?  Can you have a look?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com,
                   |                            |hubicka at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (7 preceding siblings ...)
  2007-09-28 12:59 ` rguenth at gcc dot gnu dot org
@ 2007-09-30 12:41 ` rguenth at gcc dot gnu dot org
  2007-09-30 12:51 ` rguenth at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-30 12:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2007-09-30 12:41 -------
Diego, we seem to have a general problem with the incremental SSA updater.
If we rename foo$ptr in

<bb 6>:
  # foo$ptr_16 = PHI <foo$ptr_18(ab)(5), D.1758_3(4)>
  p_12 = foo$ptr_16;
  foo$ptr_19(ab) = 0B;
  p_15 = foo$ptr_16;
  p_4 = foo$ptr_16;
  p_5 = foo$ptr_16;
  D.1781_6 = foo$ptr_16->_vptr.Foo;
  D.1782_7 = *D.1781_6;
  OBJ_TYPE_REF(D.1782_7;foo$ptr_16->0) (foo$ptr_16);
  goto <bb 8>;

it apperantly does not deal correctly with the lifetimes of foo$ptr_16 and
foo$ptr_19(ab) overlapping.  Note that the SSA_NAME_OCCURS_IN_ABNORMAL_PHI
flags are correct, foo$ptr_16 does not live across an EH edge (but just
local in BB 6).  Still, for this flag to prevent creating overlapping life
ranges it would have need to be set on foo$ptr_16 as well.

[In the testcase the final inliner is the first one to cause renaming of
foo$ptr, the early SRA pass introduces the life-range overlap (but hidden
by a copy chain) and the first copyprop makes it obviously visible (that's
the dump from above)]


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dnovillo at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (8 preceding siblings ...)
  2007-09-30 12:41 ` rguenth at gcc dot gnu dot org
@ 2007-09-30 12:51 ` rguenth at gcc dot gnu dot org
  2007-09-30 13:41 ` dnovillo at google dot com
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-09-30 12:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2007-09-30 12:51 -------
Zdenek may also have an idea?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rakdver at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (9 preceding siblings ...)
  2007-09-30 12:51 ` rguenth at gcc dot gnu dot org
@ 2007-09-30 13:41 ` dnovillo at google dot com
  2007-09-30 14:01 ` rguenther at suse dot de
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: dnovillo at google dot com @ 2007-09-30 13:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from dnovillo at google dot com  2007-09-30 13:41 -------
Subject: Re:  [4.3 Regression] wrong code with -O

On 30 Sep 2007 12:41:03 -0000, rguenth at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #9 from rguenth at gcc dot gnu dot org  2007-09-30 12:41 -------
> Diego, we seem to have a general problem with the incremental SSA updater.
> If we rename foo$ptr in
>
> <bb 6>:
>   # foo$ptr_16 = PHI <foo$ptr_18(ab)(5), D.1758_3(4)>
>   p_12 = foo$ptr_16;
>   foo$ptr_19(ab) = 0B;
>   p_15 = foo$ptr_16;
>   p_4 = foo$ptr_16;
>   p_5 = foo$ptr_16;
>   D.1781_6 = foo$ptr_16->_vptr.Foo;
>   D.1782_7 = *D.1781_6;
>   OBJ_TYPE_REF(D.1782_7;foo$ptr_16->0) (foo$ptr_16);
>   goto <bb 8>;

Is the symbol foo$ptr being marked for renaming?  If so, that's wrong.
 A gimple register symbol cannot be marked for renaming if there are
overlapping live ranges in its SSA names.  We don't have a general
mechanism to prevent that.  Mostly because we do not keep track when
OLRs are created.  The generic SSA updating mechanism has no cheap way
of checking that.


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (10 preceding siblings ...)
  2007-09-30 13:41 ` dnovillo at google dot com
@ 2007-09-30 14:01 ` rguenther at suse dot de
  2007-10-01 19:55 ` aoliva at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: rguenther at suse dot de @ 2007-09-30 14:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from rguenther at suse dot de  2007-09-30 14:01 -------
Subject: Re:  [4.3 Regression] wrong code with
 -O

On Sun, 30 Sep 2007, dnovillo at google dot com wrote:

> > ------- Comment #9 from rguenth at gcc dot gnu dot org  2007-09-30 12:41 -------
> > Diego, we seem to have a general problem with the incremental SSA updater.
> > If we rename foo$ptr in
> >
> > <bb 6>:
> >   # foo$ptr_16 = PHI <foo$ptr_18(ab)(5), D.1758_3(4)>
> >   p_12 = foo$ptr_16;
> >   foo$ptr_19(ab) = 0B;
> >   p_15 = foo$ptr_16;
> >   p_4 = foo$ptr_16;
> >   p_5 = foo$ptr_16;
> >   D.1781_6 = foo$ptr_16->_vptr.Foo;
> >   D.1782_7 = *D.1781_6;
> >   OBJ_TYPE_REF(D.1782_7;foo$ptr_16->0) (foo$ptr_16);
> >   goto <bb 8>;
> 
> Is the symbol foo$ptr being marked for renaming?  If so, that's wrong.
>  A gimple register symbol cannot be marked for renaming if there are
> overlapping live ranges in its SSA names.  We don't have a general
> mechanism to prevent that.  Mostly because we do not keep track when
> OLRs are created.  The generic SSA updating mechanism has no cheap way
> of checking that.

Yes, it is marked for renaming by the inliner.  Somehow the inliner
assumes there are no OLRs:

...
   The function mark PHI_RESULT of such PHI nodes for renaming; it is
   safe the EH edges are abnormal and SSA_NAME_OCCURS_IN_ABNORMAL_PHI
   must be set.  This means, that there will be no overlapping live ranges
   for the underlying symbol.

   This might change in future if we allow redirecting of EH edges and
   we might want to change way build CFG pre-inlining to include
   all the possible edges then.  */

static void
update_ssa_across_eh_edges (basic_block bb)
{
  edge e;
  edge_iterator ei;

  FOR_EACH_EDGE (e, ei, bb->succs)
    if (!e->dest->aux
        || ((basic_block)e->dest->aux)->index == ENTRY_BLOCK)
      {
        tree phi;

        gcc_assert (e->flags & EDGE_EH);
        for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
          {
            gcc_assert (SSA_NAME_OCCURS_IN_ABNORMAL_PHI
                        (PHI_RESULT (phi)));
            mark_sym_for_renaming
              (SSA_NAME_VAR (PHI_RESULT (phi)));
          }
      }
}


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (11 preceding siblings ...)
  2007-09-30 14:01 ` rguenther at suse dot de
@ 2007-10-01 19:55 ` aoliva at gcc dot gnu dot org
  2007-10-02  1:38 ` aoliva at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-01 19:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from aoliva at gcc dot gnu dot org  2007-10-01 19:55 -------
Patch at http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00061.html is quite
likely to fix this.


-- 

aoliva at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aoliva at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (12 preceding siblings ...)
  2007-10-01 19:55 ` aoliva at gcc dot gnu dot org
@ 2007-10-02  1:38 ` aoliva at gcc dot gnu dot org
  2007-10-03  1:05 ` aoliva at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-02  1:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from aoliva at gcc dot gnu dot org  2007-10-02 01:38 -------
Subject: Bug 33572

Author: aoliva
Date: Tue Oct  2 01:37:59 2007
New Revision: 128939

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128939
Log:
PR tree-optimization/33572
* tree-cfg.c (verify_stmts): Check for missing PHI defs.
* tree-inline.c (update_ssa_across_eh_edges): Renamed to...
(update_ssa_across_abnormal_edges): ... this.  Set slots in the
return PHI node.
(copy_edges_for_bb): Handle nonlocal label edges.
(make_nonlocal_label_edges): Deleted.
(optimize_inline_calls): Don't call it.

Modified:
    branches/var-tracking-assignments-branch/gcc/ChangeLog.vta
    branches/var-tracking-assignments-branch/gcc/tree-cfg.c
    branches/var-tracking-assignments-branch/gcc/tree-inline.c


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (13 preceding siblings ...)
  2007-10-02  1:38 ` aoliva at gcc dot gnu dot org
@ 2007-10-03  1:05 ` aoliva at gcc dot gnu dot org
  2007-10-06 11:45 ` aoliva at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-03  1:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from aoliva at gcc dot gnu dot org  2007-10-03 01:04 -------
Confirmed, the patch fixes it.


-- 

aoliva at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |aoliva at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (14 preceding siblings ...)
  2007-10-03  1:05 ` aoliva at gcc dot gnu dot org
@ 2007-10-06 11:45 ` aoliva at gcc dot gnu dot org
  2007-10-07 14:40 ` hjl at lucon dot org
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-06 11:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from aoliva at gcc dot gnu dot org  2007-10-06 11:44 -------
Subject: Bug 33572

Author: aoliva
Date: Sat Oct  6 11:43:56 2007
New Revision: 129051

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129051
Log:
gcc/ChangeLog:
PR tree-optimization/33572
* tree-cfg.c (verify_stmts): Check for missing PHI defs.
* tree-inline.c (update_ssa_across_eh_edges): Renamed to...
(update_ssa_across_abnormal_edges): ... this.  Set slots in the
return PHI node.
(copy_edges_for_bb): Handle nonlocal label edges.
(make_nonlocal_label_edges): Deleted.
(optimize_inline_calls): Don't call it.
gcc/testsuite/ChangeLog:
PR tree-optimization/33572
* g++.dg/torture/pr33572.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr33572.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
    trunk/gcc/tree-inline.c


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (15 preceding siblings ...)
  2007-10-06 11:45 ` aoliva at gcc dot gnu dot org
@ 2007-10-07 14:40 ` hjl at lucon dot org
  2007-10-08 16:42 ` danglin at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: hjl at lucon dot org @ 2007-10-07 14:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from hjl at lucon dot org  2007-10-07 14:39 -------
(In reply to comment #16)
> Subject: Bug 33572
> 
> Author: aoliva
> Date: Sat Oct  6 11:43:56 2007
> New Revision: 129051
> 
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129051
> Log:
> gcc/ChangeLog:
> PR tree-optimization/33572
> * tree-cfg.c (verify_stmts): Check for missing PHI defs.
> * tree-inline.c (update_ssa_across_eh_edges): Renamed to...
> (update_ssa_across_abnormal_edges): ... this.  Set slots in the
> return PHI node.
> (copy_edges_for_bb): Handle nonlocal label edges.
> (make_nonlocal_label_edges): Deleted.
> (optimize_inline_calls): Don't call it.
> gcc/testsuite/ChangeLog:
> PR tree-optimization/33572
> * g++.dg/torture/pr33572.C: New.
> 
> Added:
>     trunk/gcc/testsuite/g++.dg/torture/pr33572.C
> Modified:
>     trunk/gcc/ChangeLog
>     trunk/gcc/testsuite/ChangeLog
>     trunk/gcc/tree-cfg.c
>     trunk/gcc/tree-inline.c
> 

g++.dg/torture/pr33572.C failed on Linux/ia32:

Executing on host:
/export/build/gnu/gcc/build-i686-linux/gcc/testsuite/g++/../../g++
-B/export/build/gnu/gcc/build-i686-linux/gcc/testsuite/g++/../../
/net/gnu-13/export/gnu/src/gcc/gcc/gcc/testsuite/g++.dg/torture/pr33572.C 
-nostdinc++
-I/export/build/gnu/gcc/build-i686-linux/i686-pc-linux-gnu/libstdc++-v3/include/i686-pc-linux-gnu
-I/export/build/gnu/gcc/build-i686-linux/i686-pc-linux-gnu/libstdc++-v3/include
-I/net/gnu-13/export/gnu/src/gcc/gcc/libstdc++-v3/libsupc++
-I/net/gnu-13/export/gnu/src/gcc/gcc/libstdc++-v3/include/backward
-I/net/gnu-13/export/gnu/src/gcc/gcc/libstdc++-v3/testsuite/util
-fmessage-length=0  -O0    -fno-show-column  
-L/export/build/gnu/gcc/build-i686-linux/i686-pc-linux-gnu/./libstdc++-v3/src/.libs

-L/export/build/gnu/gcc/build-i686-linux/i686-pc-linux-gnu/./libstdc++-v3/src/.libs
-L/export/build/gnu/gcc/build-i686-linux/i686-pc-linux-gnu/./libiberty  -lm  
-o ./pr33572.exe    (timeout = 300)
/tmp/ccSsvTAh.o: In function `vector::deallocate(int*)':^M
pr33572.C:(.text._ZN6vector10deallocateEPi[_ZN6vector10deallocateEPi]+0x24):
undefined reference to `__gnu_cxx::__pool<true>::_M_reclaim_block(char*,
unsigned long)'^M
collect2: ld returned 1 exit status^M


-- 

hjl at lucon dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl at lucon dot org


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (16 preceding siblings ...)
  2007-10-07 14:40 ` hjl at lucon dot org
@ 2007-10-08 16:42 ` danglin at gcc dot gnu dot org
  2007-10-08 23:57 ` aoliva at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: danglin at gcc dot gnu dot org @ 2007-10-08 16:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from danglin at gcc dot gnu dot org  2007-10-08 16:41 -------
I see the same failure as HJL on hppa-unknown-linux-gnu.


-- 

danglin at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (17 preceding siblings ...)
  2007-10-08 16:42 ` danglin at gcc dot gnu dot org
@ 2007-10-08 23:57 ` aoliva at gcc dot gnu dot org
  2007-10-09  4:47 ` aoliva at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-08 23:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from aoliva at gcc dot gnu dot org  2007-10-08 23:57 -------
Subject: Bug 33572

Author: aoliva
Date: Mon Oct  8 23:57:20 2007
New Revision: 129144

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129144
Log:
PR tree-optimization/33572
* g++.dg/torture/pr33572.C: Replace with complete test.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/torture/pr33572.C


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (18 preceding siblings ...)
  2007-10-08 23:57 ` aoliva at gcc dot gnu dot org
@ 2007-10-09  4:47 ` aoliva at gcc dot gnu dot org
  2007-10-09  4:48 ` aoliva at gcc dot gnu dot org
  2007-10-15 17:08 ` aoliva at gcc dot gnu dot org
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-09  4:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from aoliva at gcc dot gnu dot org  2007-10-09 04:47 -------
Subject: Bug 33572

Author: aoliva
Date: Tue Oct  9 04:46:49 2007
New Revision: 129151

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129151
Log:
PR tree-optimization/33572
* tree-inline.c (update_ssa_across_abnormal_edges): Tolerate
the absence of a corresponding edge from the exit block.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-inline.c


-- 


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (19 preceding siblings ...)
  2007-10-09  4:47 ` aoliva at gcc dot gnu dot org
@ 2007-10-09  4:48 ` aoliva at gcc dot gnu dot org
  2007-10-15 17:08 ` aoliva at gcc dot gnu dot org
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-09  4:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #21 from aoliva at gcc dot gnu dot org  2007-10-09 04:48 -------
Fixed.


-- 

aoliva at gcc dot gnu dot org changed:

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


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


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

* [Bug tree-optimization/33572] [4.3 Regression] wrong code with -O
  2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
                   ` (20 preceding siblings ...)
  2007-10-09  4:48 ` aoliva at gcc dot gnu dot org
@ 2007-10-15 17:08 ` aoliva at gcc dot gnu dot org
  21 siblings, 0 replies; 23+ messages in thread
From: aoliva at gcc dot gnu dot org @ 2007-10-15 17:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #22 from aoliva at gcc dot gnu dot org  2007-10-15 17:07 -------
Subject: Bug 33572

Author: aoliva
Date: Mon Oct 15 17:07:20 2007
New Revision: 129356

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129356
Log:
gcc/ChangeLog:
PR tree-optimization/33735
PR tree-optimization/33572
* tree-inline.c (update_ssa_across_abnormal_edges): Revert
2007-10-09's change.
* except.c (duplicate_eh_regions): Don't look for prev_try
beyond ERT_ALLOWED_EXCEPTIONS with an empty list.
gcc/testsuite/ChangeLog:
PR tree-optimization/33735
* g++.dg/torture/pr33735.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr33735.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/except.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c


-- 


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


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

end of thread, other threads:[~2007-10-15 17:08 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-27 16:03 [Bug c++/33572] New: wrong code with -O wouter dot vermaelen at scarlet dot be
2007-09-27 16:37 ` [Bug c++/33572] " pcarlini at suse dot de
2007-09-27 20:21 ` belyshev at depni dot sinp dot msu dot ru
2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
2007-09-27 20:31 ` wouter dot vermaelen at scarlet dot be
2007-09-27 21:03 ` [Bug tree-optimization/33572] [4.3 Regression] " rguenth at gcc dot gnu dot org
2007-09-27 21:19 ` pcarlini at suse dot de
2007-09-28 12:28 ` rguenth at gcc dot gnu dot org
2007-09-28 12:59 ` rguenth at gcc dot gnu dot org
2007-09-30 12:41 ` rguenth at gcc dot gnu dot org
2007-09-30 12:51 ` rguenth at gcc dot gnu dot org
2007-09-30 13:41 ` dnovillo at google dot com
2007-09-30 14:01 ` rguenther at suse dot de
2007-10-01 19:55 ` aoliva at gcc dot gnu dot org
2007-10-02  1:38 ` aoliva at gcc dot gnu dot org
2007-10-03  1:05 ` aoliva at gcc dot gnu dot org
2007-10-06 11:45 ` aoliva at gcc dot gnu dot org
2007-10-07 14:40 ` hjl at lucon dot org
2007-10-08 16:42 ` danglin at gcc dot gnu dot org
2007-10-08 23:57 ` aoliva at gcc dot gnu dot org
2007-10-09  4:47 ` aoliva at gcc dot gnu dot org
2007-10-09  4:48 ` aoliva at gcc dot gnu dot org
2007-10-15 17:08 ` aoliva at gcc dot gnu dot org

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).