From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12842 invoked by alias); 22 Dec 2011 23:27:48 -0000 Received: (qmail 12832 invoked by uid 22791); 22 Dec 2011 23:27:47 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Thu, 22 Dec 2011 23:27:34 +0000 From: "rearnsha at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/51643] Incorrect code produced for tail-call of weak function with -O2/-O3 option Date: Fri, 23 Dec 2011 00:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rearnsha at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rearnsha at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: 2011-12/txt/msg02509.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51643 --- Comment #14 from Richard Earnshaw 2011-12-22 23:27:29 UTC --- Because the ABI says it only works for bare metal. On a system with shared libraries, you can't tell at static link time if a weak symbol will be resolved by a shared library, so it has to left up to the dynamic linker which will fill in a PLT stub. Once you have those, it's pretty hard to make the call become a stub (and even if it were, it wouldn't be a NOP (the linker would have to turn the call into something that simply returned as the PLT sequence can't be patched). Tail-calling PLT sequences is perfectly safe, so there's no reason not to perform the optimization.