public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/47205] New: GCC emits optimized out noinline function
@ 2011-01-07 11:45 d.g.gorbachev at gmail dot com
  2011-01-07 12:48 ` Jan Hubicka
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-01-07 11:45 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: GCC emits optimized out noinline function
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: d.g.gorbachev@gmail.com


$ gcc -O2 -flto -fwhole-program main.c foo.c
$ nm a.out | grep foo
08048380 t foo.1988

========= main.c ========
extern int foo(void);

int main(void)
{
  return foo() * 0;
}
=========================

========= foo.c =========
__attribute__((noinline))
int foo(void)
{
  return 0x2a;
}
=========================


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

* Re: [Bug lto/47205] New: GCC emits optimized out noinline function
  2011-01-07 11:45 [Bug lto/47205] New: GCC emits optimized out noinline function d.g.gorbachev at gmail dot com
@ 2011-01-07 12:48 ` Jan Hubicka
  2011-01-07 12:52 ` [Bug lto/47205] " hubicka at ucw dot cz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jan Hubicka @ 2011-01-07 12:48 UTC (permalink / raw)
  To: d.g.gorbachev at gmail dot com; +Cc: gcc-bugs

> extern int foo(void);
> 
> int main(void)
> {
>   return foo() * 0;
> }
This is because gimple part of optimizers for some reason leads to the following in the optimized dump:
main ()
{
<bb 2>:
  foo ();
  return 0;

}
and only RTL optimizers do the trick.  
This is weird since pure/const detect function as pure (seen in pure-const dump)

Read info for foo/2  const nothrow
  pure const state: const
  previously known state: const

but tree-ssa-dce apparently fails to remove the statement.  I guess it is
confused by lack of return value.  I will take a look.  But this is
tree-optimization bug.

Honza


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

* [Bug lto/47205] GCC emits optimized out noinline function
  2011-01-07 11:45 [Bug lto/47205] New: GCC emits optimized out noinline function d.g.gorbachev at gmail dot com
  2011-01-07 12:48 ` Jan Hubicka
@ 2011-01-07 12:52 ` hubicka at ucw dot cz
  2011-01-07 12:58 ` [Bug tree-optimization/47205] " hubicka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hubicka at ucw dot cz @ 2011-01-07 12:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jan Hubicka <hubicka at ucw dot cz> 2011-01-07 12:47:23 UTC ---
> extern int foo(void);
> 
> int main(void)
> {
>   return foo() * 0;
> }
This is because gimple part of optimizers for some reason leads to the
following in the optimized dump:
main ()
{
<bb 2>:
  foo ();
  return 0;

}
and only RTL optimizers do the trick.  
This is weird since pure/const detect function as pure (seen in pure-const
dump)

Read info for foo/2  const nothrow
  pure const state: const
  previously known state: const

but tree-ssa-dce apparently fails to remove the statement.  I guess it is
confused by lack of return value.  I will take a look.  But this is
tree-optimization bug.

Honza


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

* [Bug tree-optimization/47205] GCC emits optimized out noinline function
  2011-01-07 11:45 [Bug lto/47205] New: GCC emits optimized out noinline function d.g.gorbachev at gmail dot com
  2011-01-07 12:48 ` Jan Hubicka
  2011-01-07 12:52 ` [Bug lto/47205] " hubicka at ucw dot cz
@ 2011-01-07 12:58 ` hubicka at gcc dot gnu.org
  2011-01-07 12:59 ` hubicka at gcc dot gnu.org
  2021-08-30  4:54 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: hubicka at gcc dot gnu.org @ 2011-01-07 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.01.07 12:48:37
          Component|lto                         |tree-optimization
                 CC|                            |hubicka at gcc dot gnu.org
     Ever Confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-01-07 12:48:37 UTC ---
recategorized thus.


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

* [Bug tree-optimization/47205] GCC emits optimized out noinline function
  2011-01-07 11:45 [Bug lto/47205] New: GCC emits optimized out noinline function d.g.gorbachev at gmail dot com
                   ` (2 preceding siblings ...)
  2011-01-07 12:58 ` [Bug tree-optimization/47205] " hubicka at gcc dot gnu.org
@ 2011-01-07 12:59 ` hubicka at gcc dot gnu.org
  2021-08-30  4:54 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: hubicka at gcc dot gnu.org @ 2011-01-07 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-01-07 12:51:58 UTC ---
Hmm, at second tought I guess statement gets improperly updated for lack of
side effect in fixup_cfg.  Will look into it.

Even that is however not enough for function to be optimized away since we
don't re-do IPA after local optimization.  This would require even more
complicating the optimization queue. So it is hard to solve fully.


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

* [Bug tree-optimization/47205] GCC emits optimized out noinline function
  2011-01-07 11:45 [Bug lto/47205] New: GCC emits optimized out noinline function d.g.gorbachev at gmail dot com
                   ` (3 preceding siblings ...)
  2011-01-07 12:59 ` hubicka at gcc dot gnu.org
@ 2021-08-30  4:54 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-30  4:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47205

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So after the final IPA pass we never update the cgraph again and prune out
unused functions.  PR 94818  is another example, there might be a few others.

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

end of thread, other threads:[~2021-08-30  4:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-07 11:45 [Bug lto/47205] New: GCC emits optimized out noinline function d.g.gorbachev at gmail dot com
2011-01-07 12:48 ` Jan Hubicka
2011-01-07 12:52 ` [Bug lto/47205] " hubicka at ucw dot cz
2011-01-07 12:58 ` [Bug tree-optimization/47205] " hubicka at gcc dot gnu.org
2011-01-07 12:59 ` hubicka at gcc dot gnu.org
2021-08-30  4:54 ` pinskia at gcc dot gnu.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).