[Bug lto/51997] New: LTO does not inline available builtin implementations
aldyh at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 25 13:20:00 GMT 2012
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);
}
More information about the Gcc-bugs
mailing list