public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/51997] New: LTO does not inline available builtin implementations
@ 2012-01-25 13:20 aldyh at gcc dot gnu.org
  2012-01-25 13:30 ` [Bug lto/51997] " aldyh at gcc dot gnu.org
  2012-06-12 21:54 ` aldyh at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-01-25 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51997
           Summary: LTO does not inline available builtin implementations
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: lto
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: aldyh@gcc.gnu.org


When LTO encounters a builtin and a corresponding local implementation of it,
the prevailing decl is always considered to be the builtin (see
lto_symtab_prevailing_decl).  This means that even if the code for a builtin is
available at LTO time, it will never be inlined into the caller.

In the code below, while compiling with "gcc -O3 -flto a.c b.c", it would be
ideal if the call to memcpy was inlined into main.  Interestingly in this case,
the call to memcpy is completely optimized away (yielding an empty main).

houston:/build/t/gcc$ cat a.c
char *dst, *src;

void *memcpy(void *, const void *, __SIZE_TYPE__); 

main()
{
  memcpy(dst, src, 123);
}
houston:/build/t/gcc$ cat b.c
extern int putchar(int);

void *memcpy(void *dst,
             const void *src,
             __SIZE_TYPE__ n) 
{
  putchar(13);
}


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

* [Bug lto/51997] LTO does not inline available builtin implementations
  2012-01-25 13:20 [Bug lto/51997] New: LTO does not inline available builtin implementations aldyh at gcc dot gnu.org
@ 2012-01-25 13:30 ` aldyh at gcc dot gnu.org
  2012-06-12 21:54 ` aldyh at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-01-25 13:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-01-25 13:18:56 UTC ---
The original discussion/motivation on this started here:
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01258.html


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

* [Bug lto/51997] LTO does not inline available builtin implementations
  2012-01-25 13:20 [Bug lto/51997] New: LTO does not inline available builtin implementations aldyh at gcc dot gnu.org
  2012-01-25 13:30 ` [Bug lto/51997] " aldyh at gcc dot gnu.org
@ 2012-06-12 21:54 ` aldyh at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-06-12 21:54 UTC (permalink / raw)
  To: gcc-bugs

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

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-06-12
     Ever Confirmed|0                           |1

--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-06-12 21:53:59 UTC ---
confirmed with:

houston:/build/t/gcc$ ./xgcc -B./ -flto a.c b.c -save-temps -o foo -O
[Leaving LTRANS /tmp/ccbO9bZt.args]
[Leaving LTRANS foo.ltrans.out]
[Leaving LTRANS /tmp/ccYBPyHk.args]
[Leaving LTRANS foo.ltrans0.o]
houston:/build/t/gcc$ cat foo.ltrans0.s
...
...

main:
.LFB0:
        .cfi_startproc
        rep
        ret
...
...


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

end of thread, other threads:[~2012-06-12 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-25 13:20 [Bug lto/51997] New: LTO does not inline available builtin implementations aldyh at gcc dot gnu.org
2012-01-25 13:30 ` [Bug lto/51997] " aldyh at gcc dot gnu.org
2012-06-12 21:54 ` aldyh 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).