public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13768] New: syntax error only when -O2
@ 2004-01-20 11:00 igodard at pacbell dot net
  2004-01-20 11:01 ` [Bug c++/13768] " igodard at pacbell dot net
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-01-20 11:00 UTC (permalink / raw)
  To: gcc-bugs

Bogus-looking syntax error when compiled -O2; no error if not. Expansion files (.ii) differ with/without too.

-- 
           Summary: syntax error only when -O2
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/13768] syntax error only when -O2
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
@ 2004-01-20 11:01 ` igodard at pacbell dot net
  2004-01-20 11:02 ` igodard at pacbell dot net
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-01-20 11:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-01-20 11:01 -------
Created an attachment (id=5531)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5531&action=view)
Compiler output (-v -save-temps)  *with no -O2*


-- 


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


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

* [Bug c++/13768] syntax error only when -O2
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
  2004-01-20 11:01 ` [Bug c++/13768] " igodard at pacbell dot net
@ 2004-01-20 11:02 ` igodard at pacbell dot net
  2004-01-20 11:03 ` igodard at pacbell dot net
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-01-20 11:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-01-20 11:02 -------
Created an attachment (id=5532)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5532&action=view)
Compiler output (-v -save-temps) *with -O2*


-- 


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


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

* [Bug c++/13768] syntax error only when -O2
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
  2004-01-20 11:01 ` [Bug c++/13768] " igodard at pacbell dot net
  2004-01-20 11:02 ` igodard at pacbell dot net
@ 2004-01-20 11:03 ` igodard at pacbell dot net
  2004-01-20 11:05 ` igodard at pacbell dot net
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-01-20 11:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-01-20 11:03 -------
Created an attachment (id=5533)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5533&action=view)
Source code (-save-temps) *with no -O2*


-- 


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


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

* [Bug c++/13768] syntax error only when -O2
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2004-01-20 11:03 ` igodard at pacbell dot net
@ 2004-01-20 11:05 ` igodard at pacbell dot net
  2004-01-20 15:49 ` [Bug c++/13768] [3.4/3.5 Regression] syntax error only when -funit-at-a-time pinskia at gcc dot gnu dot org
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-01-20 11:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-01-20 11:05 -------
Created an attachment (id=5534)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5534&action=view)
Source code (-save-temps) *with -O2*


-- 


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


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

* [Bug c++/13768] [3.4/3.5 Regression] syntax error only when -funit-at-a-time
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2004-01-20 11:05 ` igodard at pacbell dot net
@ 2004-01-20 15:49 ` pinskia at gcc dot gnu dot org
  2004-01-20 17:18 ` [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function bangerth at dealii dot org
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-20 15:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-20 15:49 -------
I need a good C++ person here but the difference happens only with -funit-at-a-time, looks like 
unit at a time is instainating different templates.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
            Summary|syntax error only when -O2  |[3.4/3.5 Regression] syntax
                   |                            |error only when -funit-at-a-
                   |                            |time
   Target Milestone|---                         |3.4.0


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


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

* [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (4 preceding siblings ...)
  2004-01-20 15:49 ` [Bug c++/13768] [3.4/3.5 Regression] syntax error only when -funit-at-a-time pinskia at gcc dot gnu dot org
@ 2004-01-20 17:18 ` bangerth at dealii dot org
  2004-01-21  3:26 ` pinskia at gcc dot gnu dot org
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: bangerth at dealii dot org @ 2004-01-20 17:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-20 17:18 -------
Here is a reduced testcase: 
--------------------------- 
template <typename T> struct X { 
    virtual void foo() const { 
      T::foo(1); 
    } 
}; 
 
template<typename T> 
void bar(T v) { 
  throw X<T>(); 
} 
 
inline void bar() { 
  bar(1); 
} 
--------------------------------- 
The testcase is illegal, since there is no int::foo function, but we 
get this: 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc -funit-at-a-time 
x.cc: In member function `void X<T>::foo() const [with T = int]': 
x.cc:13:   instantiated from here 
x.cc:3: error: `foo' is not a member of `int' 
 
In other words, with -funit-at-a-time, gcc tries to lay down a copy of 
bar(), where it doesn't do that without that flag. Since there is no 
reason to do that, this is a bug, I guess. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
          Component|c++                         |optimization
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-20 17:18:22
               date|                            |
            Summary|[3.4/3.5 Regression] syntax |[3.4/3.5 Regression] -funit-
                   |error only when -funit-at-a-|at-a-time compiles unused
                   |time                        |inline function


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


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

* [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (5 preceding siblings ...)
  2004-01-20 17:18 ` [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function bangerth at dealii dot org
@ 2004-01-21  3:26 ` pinskia at gcc dot gnu dot org
  2004-01-21  5:22 ` igodard at pacbell dot net
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-21  3:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-21 03:26 -------
Mark, I think bug should be closed as will not fix as the code is invalid but compiling without 
-funit-at-a-time does not reject unless you want to keep it open for that in which case this is not a 
regression at all.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org
           Severity|critical                    |normal
           Keywords|                            |accepts-invalid


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


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

* [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (6 preceding siblings ...)
  2004-01-21  3:26 ` pinskia at gcc dot gnu dot org
@ 2004-01-21  5:22 ` igodard at pacbell dot net
  2004-01-21  7:44 ` pinskia at gcc dot gnu dot org
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-01-21  5:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-01-21 05:22 -------
Beg pardon, but code is *not* invalid. Standard clearly states that unused template functions are not compiled and may be invalid for particular template arguments. In the reduced example the template function is invoked from a non-inline function, but in the original the template is invoked from another template that is not itself instantiated. I think :-)

Even in the reduced - what's the point of "inline" if it causes unused template intantiations to clutter the executable with template bodies that cannot be called? If the standard required that the template be syntax checked just because it appears in an (uncalled) inline, then syntax check it - but don't instantiate it and clutter the executable.



-- 


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


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

* [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (7 preceding siblings ...)
  2004-01-21  5:22 ` igodard at pacbell dot net
@ 2004-01-21  7:44 ` pinskia at gcc dot gnu dot org
  2004-01-21 13:37 ` bangerth at dealii dot org
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-21  7:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-21 07:44 -------
(In reply to comment #8)
> Beg pardon, but code is *not* invalid. Standard clearly states that unused template functions are 
not compiled and may be invalid for particular template arguments. In the reduced example the 
template function is invoked from a non-inline function, but in the original the template is invoked 
from another template that is not itself instantiated. I think :-)
The above is correct but note the the function is virtual.

> Even in the reduced - what's the point of "inline" if it causes unused template intantiations to 
clutter the executable with template bodies that cannot be called? If the standard required that the 
template be syntax checked just because it appears in an (uncalled) inline, then syntax check it - 
but don't instantiate it and clutter the executable.

I could not find any where in my reading of the standard which says that inline functions are just
syntax checked and not done the full name lookup and such.  Note nothing ever gets emitted for 
code that is corrected.

-- 


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


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

* [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (8 preceding siblings ...)
  2004-01-21  7:44 ` pinskia at gcc dot gnu dot org
@ 2004-01-21 13:37 ` bangerth at dealii dot org
  2004-01-31 18:22 ` pinskia at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: bangerth at dealii dot org @ 2004-01-21 13:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-21 13:37 -------
I think the validity of the test is immaterial -- the testcase shows 
a deficiency in the implementation of -funit-at-a-time. This is 
certainly not a big deal, but it's a bug that we should eventually 
get around to fixing. I concede that it should be lower priority 
than most of our bugs, and shouldn't block a release. 
 
W. 

-- 


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


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

* [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (9 preceding siblings ...)
  2004-01-21 13:37 ` bangerth at dealii dot org
@ 2004-01-31 18:22 ` pinskia at gcc dot gnu dot org
  2004-02-03  8:39 ` [Bug c++/13768] " ebotcazou at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-31 18:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-31 18:22 -------
*** Bug 13942 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mattyt-bugzilla at tpg dot
                   |                            |com dot au


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (10 preceding siblings ...)
  2004-01-31 18:22 ` pinskia at gcc dot gnu dot org
@ 2004-02-03  8:39 ` ebotcazou at gcc dot gnu dot org
  2004-02-03  9:25 ` mmitchel at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2004-02-03  8:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-02-03 08:38 -------
With -funit-at-a-time, the C++ front-end (decl2.c:maybe_emit_vtables) emits the
vtable for struct X, while it doesn't do so without -funit-at-a-time.

The difference in the behaviour boils down to this macro in cp-tree.h:

/* DECL_NEEDED_P holds of a declaration when we need to emit its
   definition.  This is true when the back-end tells us that
   the symbol has been referenced in the generated code.  If, however,
   we are not generating code, then it is also true when a symbol has
   just been used somewhere, even if it's not really needed.  We need
   anything that isn't comdat, but we don't know for sure whether or
   not something is comdat until end-of-file.  */
#define DECL_NEEDED_P(DECL)					\
  ((at_eof && TREE_PUBLIC (DECL) && !DECL_COMDAT (DECL))	\
   || (DECL_ASSEMBLER_NAME_SET_P (DECL)				\
       && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)))	\
   || (((flag_syntax_only || flag_unit_at_a_time) && TREE_USED (DECL))))


According to the comment, it seems that -funit-at-a-time behaves like
-fsyntax-only, that is it may emit DECLs that are not really needed.


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


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (11 preceding siblings ...)
  2004-02-03  8:39 ` [Bug c++/13768] " ebotcazou at gcc dot gnu dot org
@ 2004-02-03  9:25 ` mmitchel at gcc dot gnu dot org
  2004-02-03 11:00 ` hubicka at ucw dot cz
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-02-03  9:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 09:25 -------
The code is indeed invalid.

When a complete object of type X<int> is created, the compiler is allowed to
emit the vtable for X, and that permits instantiating the virtual functions.

However, this is an optimization deficiency in -funit-at-a-time.

I've therefore assigned the bug to Jan.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jh at suse dot cz
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (12 preceding siblings ...)
  2004-02-03  9:25 ` mmitchel at gcc dot gnu dot org
@ 2004-02-03 11:00 ` hubicka at ucw dot cz
  2004-02-03 15:46 ` mark at codesourcery dot com
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-02-03 11:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-02-03 11:00 -------
Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function

> 
> ------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 09:25 -------
> The code is indeed invalid.
> 
> When a complete object of type X<int> is created, the compiler is allowed to
> emit the vtable for X, and that permits instantiating the virtual functions.
> 
> However, this is an optimization deficiency in -funit-at-a-time.

Yes, the problem is that all dependencies are resolved before
optimization is done.  I am planning to address this by doing early pass
of tree-ssa optimization before inlining and cgraph construction.  That
way we should catch majority of cases.
I also plan to deffer output of datastrctures to the very end of
compilation and use information about what was really used by backend.

Honza
> 
> I've therefore assigned the bug to Jan.
> 
> -- 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>          AssignedTo|unassigned at gcc dot gnu   |jh at suse dot cz
>                    |dot org                     |
>              Status|NEW                         |ASSIGNED
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13768
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.


-- 


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (13 preceding siblings ...)
  2004-02-03 11:00 ` hubicka at ucw dot cz
@ 2004-02-03 15:46 ` mark at codesourcery dot com
  2004-02-03 15:53 ` jh at suse dot cz
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: mark at codesourcery dot com @ 2004-02-03 15:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mark at codesourcery dot com  2004-02-03 15:46 -------
Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles
 unused inline function

hubicka at ucw dot cz wrote:

>------- Additional Comments From hubicka at ucw dot cz  2004-02-03 11:00 -------
>Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
>
>  
>
>>------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 09:25 -------
>>The code is indeed invalid.
>>
>>When a complete object of type X<int> is created, the compiler is allowed to
>>emit the vtable for X, and that permits instantiating the virtual functions.
>>
>>However, this is an optimization deficiency in -funit-at-a-time.
>>    
>>
>
>Yes, the problem is that all dependencies are resolved before
>optimization is done.  I am planning to address this by doing early pass
>of tree-ssa optimization before inlining and cgraph construction.  That
>way we should catch majority of cases.
>I also plan to deffer output of datastrctures to the very end of
>compilation and use information about what was really used by backend.
>
>Honza
>
What do you suggest, if anything, for GCC 3.4?

(This is potentially a regression with respect to the size of the 
generated code.  There is lots of code with trivial constructors that, 
after inlining, will be eliminated.)



-- 


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (14 preceding siblings ...)
  2004-02-03 15:46 ` mark at codesourcery dot com
@ 2004-02-03 15:53 ` jh at suse dot cz
  2004-02-03 15:59 ` jh at suse dot cz
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: jh at suse dot cz @ 2004-02-03 15:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jh at suse dot cz  2004-02-03 15:53 -------
Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function

> 
> ------- Additional Comments From mark at codesourcery dot com  2004-02-03 15:46 -------
> Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles
>  unused inline function
> 
> hubicka at ucw dot cz wrote:
> 
> >------- Additional Comments From hubicka at ucw dot cz  2004-02-03 11:00 -------
> >Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
> >
> >  
> >
> >>------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 09:25 -------
> >>The code is indeed invalid.
> >>
> >>When a complete object of type X<int> is created, the compiler is allowed to
> >>emit the vtable for X, and that permits instantiating the virtual functions.
> >>
> >>However, this is an optimization deficiency in -funit-at-a-time.
> >>    
> >>
> >
> >Yes, the problem is that all dependencies are resolved before
> >optimization is done.  I am planning to address this by doing early pass
> >of tree-ssa optimization before inlining and cgraph construction.  That
> >way we should catch majority of cases.
> >I also plan to deffer output of datastrctures to the very end of
> >compilation and use information about what was really used by backend.
> >
> >Honza
> >
> What do you suggest, if anything, for GCC 3.4?
> 
> (This is potentially a regression with respect to the size of the 
> generated code.  There is lots of code with trivial constructors that, 
> after inlining, will be eliminated.)

I think we can keep it as it is now.  I did quite huge amount of
measuring and the unit-at-a-time is a win for majority of C++ programs,
so I think the other benefits outweight it.
It is quite dificult to solve with current framework, unforutnately,
since we discover such facts only during RTL expansion pass and because
we mix analysis and optimization, we want to order things in a way so
calees are compiled first and thus we can't take them back.  My CFG
transparent expansion/inlining project is all about getting this
chicken-egg problem broken up.

Note that if the constructor get inlined to all call sites, it's out of
line copy will be elliminated.  We only lose in the case the
constructor is not inlined for whatever reason and then the call site is
removed later, for instance because the code turns out to be dead.  This
don't seems to be terribly common in real code from what I've seen.

Another problem is that we don't have ability to elliminate static
cosntructors when static variable turns out to be unnecesary.  Richard
did some work on this, but didn't finished it, I plan to look into it
after tree-SSA merge.

Honza
> 
> 
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13768
> 
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.


-- 


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (15 preceding siblings ...)
  2004-02-03 15:53 ` jh at suse dot cz
@ 2004-02-03 15:59 ` jh at suse dot cz
  2004-02-03 16:02 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: jh at suse dot cz @ 2004-02-03 15:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jh at suse dot cz  2004-02-03 15:59 -------
Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function

> 
> ------- Additional Comments From jh at suse dot cz  2004-02-03 15:53 -------
> Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
> 
> > 
> > ------- Additional Comments From mark at codesourcery dot com  2004-02-03 15:46 -------
> > Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles
> >  unused inline function
> > 
> > hubicka at ucw dot cz wrote:
> > 
> > >------- Additional Comments From hubicka at ucw dot cz  2004-02-03 11:00 -------
> > >Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
> > >
> > >  
> > >
> > >>------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 09:25 -------
> > >>The code is indeed invalid.
> > >>
> > >>When a complete object of type X<int> is created, the compiler is allowed to
> > >>emit the vtable for X, and that permits instantiating the virtual functions.
> > >>
> > >>However, this is an optimization deficiency in -funit-at-a-time.
> > >>    
> > >>
> > >
> > >Yes, the problem is that all dependencies are resolved before
> > >optimization is done.  I am planning to address this by doing early pass
> > >of tree-ssa optimization before inlining and cgraph construction.  That
> > >way we should catch majority of cases.
> > >I also plan to deffer output of datastrctures to the very end of
> > >compilation and use information about what was really used by backend.
> > >
> > >Honza
> > >
> > What do you suggest, if anything, for GCC 3.4?
> > 
> > (This is potentially a regression with respect to the size of the 
> > generated code.  There is lots of code with trivial constructors that, 
> > after inlining, will be eliminated.)
> 
> I think we can keep it as it is now.  I did quite huge amount of
> measuring and the unit-at-a-time is a win for majority of C++ programs,
> so I think the other benefits outweight it.
> It is quite dificult to solve with current framework, unforutnately,
> since we discover such facts only during RTL expansion pass and because
> we mix analysis and optimization, we want to order things in a way so
> calees are compiled first and thus we can't take them back.  My CFG
> transparent expansion/inlining project is all about getting this
> chicken-egg problem broken up.
> 
> Note that if the constructor get inlined to all call sites, it's out of
> line copy will be elliminated.  We only lose in the case the
> constructor is not inlined for whatever reason and then the call site is
> removed later, for instance because the code turns out to be dead.  This
> don't seems to be terribly common in real code from what I've seen.
> 
> Another problem is that we don't have ability to elliminate static
> cosntructors when static variable turns out to be unnecesary.  Richard
> did some work on this, but didn't finished it, I plan to look into it
> after tree-SSA merge.

Actually looking deeper into this specific testcase,  I believe that if
the source program was correct, unit-at-a-time would emit empty file
too, since there is no entry point from where the call in question can
be reached, so it just builds the program representation in memory prior
optimizing it.
This is because of your request to change C++ frontend that way (my
initial patch didn't force instantiation of all TREE_USED templates).

I think this is correct thing - GCC should error out on this testcase.
Why it is considered a bug at first place?

Honza
> 
> Honza
> > 
> > 
> > 
> > -- 
> > 
> > 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13768
> > 
> > ------- You are receiving this mail because: -------
> > You are the assignee for the bug, or are watching the assignee.
> 
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13768
> 
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.


-- 


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (16 preceding siblings ...)
  2004-02-03 15:59 ` jh at suse dot cz
@ 2004-02-03 16:02 ` mmitchel at gcc dot gnu dot org
  2004-02-03 16:04 ` hubicka at ucw dot cz
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-02-03 16:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 16:02 -------
Jan believes that this is (a) hard to fix, and (b) not critical based on
measurements of real code, so I've postponed this until GCC 3.5.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.0                       |3.5.0


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (17 preceding siblings ...)
  2004-02-03 16:02 ` mmitchel at gcc dot gnu dot org
@ 2004-02-03 16:04 ` hubicka at ucw dot cz
  2004-02-03 17:22 ` mark at codesourcery dot com
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at ucw dot cz @ 2004-02-03 16:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at ucw dot cz  2004-02-03 16:04 -------
Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function

> 
> ------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-03 16:02 -------
> Jan believes that this is (a) hard to fix, and (b) not critical based on
> measurements of real code, so I've postponed this until GCC 3.5.

Actually I think this bugreport shall be closed (or maintained as bug
about accepting illegal code in non-unit-at-a-time compilation mode),
see me other mail.

Honza
> 
> -- 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>    Target Milestone|3.4.0                       |3.5.0
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13768
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.


-- 


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


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

* [Bug c++/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (18 preceding siblings ...)
  2004-02-03 16:04 ` hubicka at ucw dot cz
@ 2004-02-03 17:22 ` mark at codesourcery dot com
  2004-02-05 17:14 ` [Bug c++/13768] C++ fails to diagnose invalid code pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: mark at codesourcery dot com @ 2004-02-03 17:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mark at codesourcery dot com  2004-02-03 17:22 -------
Subject: Re:  [3.4/3.5 Regression] -funit-at-a-time compiles
 unused inline function


>Actually looking deeper into this specific testcase,  I believe that if
>the source program was correct, unit-at-a-time would emit empty file
>too, since there is no entry point from where the call in question can
>be reached, so it just builds the program representation in memory prior
>optimizing it.
>This is because of your request to change C++ frontend that way (my
>initial patch didn't force instantiation of all TREE_USED templates).
>
>I think this is correct thing - GCC should error out on this testcase.
>Why it is considered a bug at first place?
>  
>
If the vtable will not actually be emitted to the object file, then this 
is not a bug, and you can close it.



-- 


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


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

* [Bug c++/13768] C++ fails to diagnose invalid code
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (19 preceding siblings ...)
  2004-02-03 17:22 ` mark at codesourcery dot com
@ 2004-02-05 17:14 ` pinskia at gcc dot gnu dot org
  2004-02-05 17:23 ` [Bug c++/13768] C++ fails to diagnose invalid code(calling a non exitsing function in a template class) in non unit-at-a-time mode giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-05 17:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-05 17:14 -------
Resummizing and changing the target.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|jh at suse dot cz           |unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW
      Known to fail|                            |3.3.3 3.4.0 3.5.0 3.1 2.95.3
      Known to work|3.3                         |
            Summary|[3.4/3.5 Regression] -funit-|C++ fails to diagnose
                   |at-a-time compiles unused   |invalid code
                   |inline function             |


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


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

* [Bug c++/13768] C++ fails to diagnose invalid code(calling a non exitsing function in a template class) in non unit-at-a-time mode
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (20 preceding siblings ...)
  2004-02-05 17:14 ` [Bug c++/13768] C++ fails to diagnose invalid code pinskia at gcc dot gnu dot org
@ 2004-02-05 17:23 ` giovannibajo at libero dot it
  2004-02-05 20:04 ` [Bug c++/13768] Incoherent behaviour in instantiation between -funit-at-a-time and -fno-unit-at-a-time igodard at pacbell dot net
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-02-05 17:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-02-05 17:23 -------
No, sorry, the code is not invalid per-se. It's just unspecified, so both the 
unit-at-a-time and the function-at-a-time behaviours are correct. Mark is 
asking if the vtable is emitted or not. If it's not emitted, then it's correct 
that the function is not instantiated, and the bug is invalid.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovannibajo at libero dot
                   |                            |it


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


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

* [Bug c++/13768] Incoherent behaviour in instantiation between -funit-at-a-time and -fno-unit-at-a-time
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (21 preceding siblings ...)
  2004-02-05 17:23 ` [Bug c++/13768] C++ fails to diagnose invalid code(calling a non exitsing function in a template class) in non unit-at-a-time mode giovannibajo at libero dot it
@ 2004-02-05 20:04 ` igodard at pacbell dot net
  2004-05-05 20:25 ` hubicka at gcc dot gnu dot org
  2004-08-03  6:03 ` pinskia at gcc dot gnu dot org
  24 siblings, 0 replies; 26+ messages in thread
From: igodard at pacbell dot net @ 2004-02-05 20:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-02-05 20:04 -------
Whether it's valid, invalid or unspecified, the user's mental model of the compilation process expects that the set of syntax errors reported should not depend on the optimization level on the command line. I suggest (for general user happiness and fewer nuisance reports) that the behavior be made invariant - whatever behavior is chosen.

Ivan

-- 


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


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

* [Bug c++/13768] Incoherent behaviour in instantiation between -funit-at-a-time and -fno-unit-at-a-time
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (22 preceding siblings ...)
  2004-02-05 20:04 ` [Bug c++/13768] Incoherent behaviour in instantiation between -funit-at-a-time and -fno-unit-at-a-time igodard at pacbell dot net
@ 2004-05-05 20:25 ` hubicka at gcc dot gnu dot org
  2004-08-03  6:03 ` pinskia at gcc dot gnu dot org
  24 siblings, 0 replies; 26+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2004-05-05 20:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From hubicka at gcc dot gnu dot org  2004-05-05 20:25 -------
Making the behaviour consistent across function-at-a-time and unit-at-a-time is 
almost impossible in this testcase without major reorganization of 
function-at-a-time.  I would rather vote to drop function-at-a-time on some of 
future releases. 
 
Honza 

-- 


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


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

* [Bug c++/13768] Incoherent behaviour in instantiation between -funit-at-a-time and -fno-unit-at-a-time
  2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
                   ` (23 preceding siblings ...)
  2004-05-05 20:25 ` hubicka at gcc dot gnu dot org
@ 2004-08-03  6:03 ` pinskia at gcc dot gnu dot org
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-03  6:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-03 06:03 -------
Fixed by:
2004-07-29  Mark Mitchell  <mark@codesourcery.com>

        * cp-tree.h (IDENTIFIER_REPO_CHOSEN): Define.
        (lang_decl_flags): Narrow the width of "languages".  Add
        repo_available_p.
        (DECL_NEEDED_P): Remove.
        (FOR_EACH_CLONE): New macro.
        (DECL_REPO_AVAILABLE_P): Likewise.
        ......

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


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


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

end of thread, other threads:[~2004-08-03  6:03 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-20 11:00 [Bug c++/13768] New: syntax error only when -O2 igodard at pacbell dot net
2004-01-20 11:01 ` [Bug c++/13768] " igodard at pacbell dot net
2004-01-20 11:02 ` igodard at pacbell dot net
2004-01-20 11:03 ` igodard at pacbell dot net
2004-01-20 11:05 ` igodard at pacbell dot net
2004-01-20 15:49 ` [Bug c++/13768] [3.4/3.5 Regression] syntax error only when -funit-at-a-time pinskia at gcc dot gnu dot org
2004-01-20 17:18 ` [Bug optimization/13768] [3.4/3.5 Regression] -funit-at-a-time compiles unused inline function bangerth at dealii dot org
2004-01-21  3:26 ` pinskia at gcc dot gnu dot org
2004-01-21  5:22 ` igodard at pacbell dot net
2004-01-21  7:44 ` pinskia at gcc dot gnu dot org
2004-01-21 13:37 ` bangerth at dealii dot org
2004-01-31 18:22 ` pinskia at gcc dot gnu dot org
2004-02-03  8:39 ` [Bug c++/13768] " ebotcazou at gcc dot gnu dot org
2004-02-03  9:25 ` mmitchel at gcc dot gnu dot org
2004-02-03 11:00 ` hubicka at ucw dot cz
2004-02-03 15:46 ` mark at codesourcery dot com
2004-02-03 15:53 ` jh at suse dot cz
2004-02-03 15:59 ` jh at suse dot cz
2004-02-03 16:02 ` mmitchel at gcc dot gnu dot org
2004-02-03 16:04 ` hubicka at ucw dot cz
2004-02-03 17:22 ` mark at codesourcery dot com
2004-02-05 17:14 ` [Bug c++/13768] C++ fails to diagnose invalid code pinskia at gcc dot gnu dot org
2004-02-05 17:23 ` [Bug c++/13768] C++ fails to diagnose invalid code(calling a non exitsing function in a template class) in non unit-at-a-time mode giovannibajo at libero dot it
2004-02-05 20:04 ` [Bug c++/13768] Incoherent behaviour in instantiation between -funit-at-a-time and -fno-unit-at-a-time igodard at pacbell dot net
2004-05-05 20:25 ` hubicka at gcc dot gnu dot org
2004-08-03  6:03 ` pinskia 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).