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: unassig...@gcc.gnu.org
        ReportedBy: al...@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);
}

Reply via email to