public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/59515] New: -Og doesn't generate out-of-line copies of inline functions like -O0 does
@ 2013-12-15 20:51 naesten at gmail dot com
  2013-12-15 21:11 ` [Bug debug/59515] " naesten at gmail dot com
  2013-12-19 13:18 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: naesten at gmail dot com @ 2013-12-15 20:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59515
           Summary: -Og doesn't generate out-of-line copies of inline
                    functions like -O0 does
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: naesten at gmail dot com

For example:

naesten@hydrogen:~/hacking/bugs/gcc$ cat Og-inline-methods.cc
struct Foo {
    int bar() {
        return 42;
    }
};

Foo foo;

int main() {
    return foo.bar() - foo.bar();
}
naesten@hydrogen:~/hacking/bugs/gcc$ g++ --version
g++ (Debian 4.8.2-1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

naesten@hydrogen:~/hacking/bugs/gcc$ g++ -Og -g Og-inline-methods.cc
naesten@hydrogen:~/hacking/bugs/gcc$ gdb a.out
GNU gdb (GDB) 7.6.1 (Debian 7.6.1-1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/naesten/hacking/bugs/gcc/a.out...done.
(gdb) start
Temporary breakpoint 1 at 0x804846d: file Og-inline-methods.cc, line 11.
Starting program: /home/naesten/hacking/bugs/gcc/a.out 
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Traceback (most recent call last):
  File "/usr/lib/debug//usr/lib/i386-linux-gnu/libstdc++.so.6.0.18-gdb.py",
line
 63, in <module>                                                               
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named libstdcxx.v6.printers

Temporary breakpoint 1, main () at Og-inline-methods.cc:11
11      }
(gdb) print foo.bar()
Cannot evaluate function -- may be inlined
(gdb) continue
Continuing.
[Inferior 1 (process 19256) exited normally]


The problem here is that I get "Cannot evaluate function -- may be inlined" for
an expression appearing in my program.  This does not happen with -O0, with the
result that I routinely build a reasonably large C++ program that I work on
with -O0 rather than -Og.

(Of course, the functions in the real program are slightly more useful than
this one is ;-)

I would prefer if an out-of-line copy would also be emitted in those
compilation units that actually call a given inline function, like happens with
-O0, but I guess even -fkeep-inline-functions *might* be preferable to this,
despite how wasteful it would be.


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

* [Bug debug/59515] -Og doesn't generate out-of-line copies of inline functions like -O0 does
  2013-12-15 20:51 [Bug debug/59515] New: -Og doesn't generate out-of-line copies of inline functions like -O0 does naesten at gmail dot com
@ 2013-12-15 21:11 ` naesten at gmail dot com
  2013-12-19 13:18 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: naesten at gmail dot com @ 2013-12-15 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Samuel Bronson <naesten at gmail dot com> ---
Oh, I meant to delete this part:

> Traceback (most recent call last):
>   File "/usr/lib/debug//usr/lib/i386-linux-gnu/libstdc++.so.6.0.18-gdb.py", line
>  63, in <module>                                                               
>     from libstdcxx.v6.printers import register_libstdcxx_printers
> ImportError: No module named libstdcxx.v6.printers

It's totally irrelevant to the present bug.

(It is an artefact of a bug in either gdb or debian's listdc++ debug package:
the file in question is getting loaded once for
"/usr/lib/debug//usr/lib/i386-linux-gnu/libstdc++.so" and once for
"/usr/lib/i386-linux-gnu/libstdc++.so", and fails the first time 'round because
it's not expecting to be called in that context...)


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

* [Bug debug/59515] -Og doesn't generate out-of-line copies of inline functions like -O0 does
  2013-12-15 20:51 [Bug debug/59515] New: -Og doesn't generate out-of-line copies of inline functions like -O0 does naesten at gmail dot com
  2013-12-15 21:11 ` [Bug debug/59515] " naesten at gmail dot com
@ 2013-12-19 13:18 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-12-19 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-12-19
                 CC|                            |hubicka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Thanks for the report - I agree that -Og should preserve an OOL copy of inlined
functions.  I'll see what I can do here (with C++ and a lot of abstraction
penalty the code size impact of that could be quite big though, and via that
also the compile-time increase).  We definitely need to avoid inlining into the
unused offline copy - but usually that's too late because we inline from the
leafs - if we don't the code-size impact is exponential ... :/

Honza, is there a way to do this in a clean way?  That is, create a clone
of all initially reachable functions that we don't inline into, but remove
the clone if the original function prevails?  That is, for

inline int bar () { return 42; }
inline int foo () { return bar() + bar(); }
int main()
{
  return foo ();
}

have main return 84 but offline copies of bar and foo while foo should still
call bar twice?

Not sure if the exponential size consideration matters for -Og which
inlines for size improvements only.


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

end of thread, other threads:[~2013-12-19 13:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-15 20:51 [Bug debug/59515] New: -Og doesn't generate out-of-line copies of inline functions like -O0 does naesten at gmail dot com
2013-12-15 21:11 ` [Bug debug/59515] " naesten at gmail dot com
2013-12-19 13:18 ` rguenth 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).