public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36959]  New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
@ 2008-07-28 23:34 pinskia at gcc dot gnu dot org
  2008-07-28 23:34 ` [Bug c++/36959] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-07-28 23:34 UTC (permalink / raw)
  To: gcc-bugs

Take:
static inline int *fromSlotB(void)
{
  static int shuf_BZZZ = 1;
  return &shuf_BZZZ;
}

int main(void)
{
  return (int)fromSlotB();
}

--- CUT ---
At -O2, fromSlotB is still being emitted even though it is unused.
It is being marked in cxx_callgraph_analyze_expr:
      else if (DECL_CONTEXT (t)
               && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
        /* If we need a static variable in a function, then we
           need the containing function.  */
        mark_decl_referenced (DECL_CONTEXT (t));

For -frepo this might be true but I don't think this is true in general.
This regression was introduced to do unit-at-a-time always for C++:
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg02615.html


-- 
           Summary: [4.2/4.3/4.4 Regression] C++ front-end causing a static
                    inline function to be emitted
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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


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

* [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
@ 2008-07-28 23:34 ` pinskia at gcc dot gnu dot org
  2008-08-04 18:41 ` rguenth at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-07-28 23:34 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.1.1 4.4.0
      Known to work|                            |3.4.0
   Target Milestone|---                         |4.2.5


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


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

* [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
  2008-07-28 23:34 ` [Bug c++/36959] " pinskia at gcc dot gnu dot org
@ 2008-08-04 18:41 ` rguenth at gcc dot gnu dot org
  2008-09-20 15:28 ` rguenth at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-08-04 18:41 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu dot
                   |                            |org
           Priority|P3                          |P2


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


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

* [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
  2008-07-28 23:34 ` [Bug c++/36959] " pinskia at gcc dot gnu dot org
  2008-08-04 18:41 ` rguenth at gcc dot gnu dot org
@ 2008-09-20 15:28 ` rguenth at gcc dot gnu dot org
  2008-09-20 18:36   ` Andrew Thomas Pinski
  2008-09-20 18:38 ` pinskia at gmail dot com
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-20 15:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-09-20 15:26 -------
What happens if you remove this piece of code?  I suspect we merely need
to keep the function declaration to emit proper debug information.


-- 


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


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

* Re: [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
  2008-09-20 15:28 ` rguenth at gcc dot gnu dot org
@ 2008-09-20 18:36   ` Andrew Thomas Pinski
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Thomas Pinski @ 2008-09-20 18:36 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs



Sent from my iPhone

On Sep 20, 2008, at 8:26 AM, "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #1 from rguenth at gcc dot gnu dot org  2008-09-20  
> 15:26 -------
> What happens if you remove this piece of code?  I suspect we merely  
> need
> to keep the function declaration to emit proper debug information.

I only tested disabling it for the non repo case and it worked and got  
the correct debugging info.

>
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36959
>


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

* [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-09-20 15:28 ` rguenth at gcc dot gnu dot org
@ 2008-09-20 18:38 ` pinskia at gmail dot com
  2008-09-20 22:00 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: pinskia at gmail dot com @ 2008-09-20 18:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gmail dot com  2008-09-20 18:36 -------
Subject: Re:  [4.2/4.3/4.4 Regression] C++ front-end causing a static inline
function to be emitted



Sent from my iPhone

On Sep 20, 2008, at 8:26 AM, "rguenth at gcc dot gnu dot org"
<gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #1 from rguenth at gcc dot gnu dot org  2008-09-20  
> 15:26 -------
> What happens if you remove this piece of code?  I suspect we merely  
> need
> to keep the function declaration to emit proper debug information.

I only tested disabling it for the non repo case and it worked and got  
the correct debugging info.

>
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36959
>


-- 


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


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

* [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-09-20 18:38 ` pinskia at gmail dot com
@ 2008-09-20 22:00 ` mmitchel at gcc dot gnu dot org
  2009-03-31 20:57 ` [Bug c++/36959] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2008-09-20 22:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mmitchel at gcc dot gnu dot org  2008-09-20 21:59 -------
I suspect that things have been improved so that this code is no longer
required.  My expectation is that in the past we only emitted the static when
we emitted the function body, so the code made sense.  But, now, with the
cgraph infrastructure, the compiler is probably perfect capable of emitting a
variable without its containing function.

Andrew raises a good point about -frepo.  The interesting question is what
happens if there is an undefined referenced to the variable, but not the
function; does collect2 arrange that we actually emit the function?

For example:

  test.h
  ------
  template <typename T> void * f(T) {
    static int i;
  }

  a.C
  ---
  #include "test.h"

  int* p = f(3);

  int main() {}

With -O2 -frepo, does this link?  I'd expect that we end up with an undefined
referenced to f<int>::i in a.o, but that this variable isn't listed in the set
of things that could be generated by recompiling a.C, so we lose.


-- 


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-09-20 22:00 ` mmitchel at gcc dot gnu dot org
@ 2009-03-31 20:57 ` jsm28 at gcc dot gnu dot org
  2009-05-22  0:32 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 20:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jsm28 at gcc dot gnu dot org  2009-03-31 20:57 -------
Closing 4.2 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2/4.3/4.4/4.5 Regression]|[4.3/4.4/4.5 Regression] C++
                   |C++ front-end causing a     |front-end causing a static
                   |static inline function to be|inline function to be
                   |emitted                     |emitted
   Target Milestone|4.2.5                       |4.3.4


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-03-31 20:57 ` [Bug c++/36959] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-05-22  0:32 ` pinskia at gcc dot gnu dot org
  2009-08-04 12:42 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-22  0:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2009-05-22 00:31 -------
*** Bug 40222 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amodra at bigpond dot net
                   |                            |dot au


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-05-22  0:32 ` pinskia at gcc dot gnu dot org
@ 2009-08-04 12:42 ` rguenth at gcc dot gnu dot org
  2009-11-03 22:26 ` jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2009-08-04 12:29 -------
GCC 4.3.4 is being released, adjusting target milestone.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.4                       |4.3.5


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-08-04 12:42 ` rguenth at gcc dot gnu dot org
@ 2009-11-03 22:26 ` jason at gcc dot gnu dot org
  2009-11-03 23:03 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 22:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-03 22:25:59
               date|                            |


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-11-03 22:26 ` jason at gcc dot gnu dot org
@ 2009-11-03 23:03 ` jason at gcc dot gnu dot org
  2009-11-03 23:49 ` jason at gcc dot gnu dot org
  2009-11-03 23:50 ` jason at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 23:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2009-11-03 23:02 -------
Subject: Bug 36959

Author: jason
Date: Tue Nov  3 23:02:41 2009
New Revision: 153878

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153878
Log:
        PR c++/36959
        * decl2.c (cxx_callgraph_analyze_expr): Don't reference a function
        just because a static variable in it is needed unless -frepo.

Added:
    trunk/gcc/testsuite/g++.dg/opt/inline16.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2009-11-03 23:03 ` jason at gcc dot gnu dot org
@ 2009-11-03 23:49 ` jason at gcc dot gnu dot org
  2009-11-03 23:50 ` jason at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 23:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2009-11-03 23:49 -------
Subject: Bug 36959

Author: jason
Date: Tue Nov  3 23:49:07 2009
New Revision: 153881

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153881
Log:
        PR c++/36959
        * decl2.c (cxx_callgraph_analyze_expr): Don't reference a function
        just because a static variable in it is needed unless -frepo.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/inline16.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/decl2.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/36959] [4.3/4.4/4.5 Regression] C++ front-end causing a static inline function to be emitted
  2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2009-11-03 23:49 ` jason at gcc dot gnu dot org
@ 2009-11-03 23:50 ` jason at gcc dot gnu dot org
  11 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 23:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jason at gcc dot gnu dot org  2009-11-03 23:50 -------
Fixed for 4.4.3 and 4.5.0.  My inclination is to leave 4.3 unfixed, but I don't
mind applying it there if other people think that's a good idea.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.3.5                       |4.4.3


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


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

end of thread, other threads:[~2009-11-03 23:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-28 23:34 [Bug c++/36959] New: [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted pinskia at gcc dot gnu dot org
2008-07-28 23:34 ` [Bug c++/36959] " pinskia at gcc dot gnu dot org
2008-08-04 18:41 ` rguenth at gcc dot gnu dot org
2008-09-20 15:28 ` rguenth at gcc dot gnu dot org
2008-09-20 18:36   ` Andrew Thomas Pinski
2008-09-20 18:38 ` pinskia at gmail dot com
2008-09-20 22:00 ` mmitchel at gcc dot gnu dot org
2009-03-31 20:57 ` [Bug c++/36959] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-05-22  0:32 ` pinskia at gcc dot gnu dot org
2009-08-04 12:42 ` rguenth at gcc dot gnu dot org
2009-11-03 22:26 ` jason at gcc dot gnu dot org
2009-11-03 23:03 ` jason at gcc dot gnu dot org
2009-11-03 23:49 ` jason at gcc dot gnu dot org
2009-11-03 23:50 ` jason 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).