From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25483 invoked by alias); 25 Jan 2012 13:15:57 -0000 Received: (qmail 25471 invoked by uid 22791); 25 Jan 2012 13:15:57 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CP X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Jan 2012 13:15:44 +0000 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/51997] New: LTO does not inline available builtin implementations Date: Wed, 25 Jan 2012 13:20:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-01/txt/msg02917.txt.bz2 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); }