From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111313 invoked by alias); 23 Mar 2015 23:56:43 -0000 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 Received: (qmail 111226 invoked by uid 48); 23 Mar 2015 23:56:39 -0000 From: "aldot at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/65534] New: tailcall not optimized away Date: Tue, 24 Mar 2015 02:19:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: aldot 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg02461.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65534 Bug ID: 65534 Summary: tailcall not optimized away Product: gcc Version: 5.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: aldot at gcc dot gnu.org CC: hubicka at ucw dot cz, rguenth at gcc dot gnu.org Maybe this could be optimized by a thunk or by creating the alias automatically or the like? Or is tailcall supposed to do this already? trunk@221345 $ gcc -Os -c missed-opt.c -o missed-opt.plain.o $ gcc -Os -c missed-opt.c -o missed-opt.manual.o -DOPTIMIZE_MANUALLY $ size missed-opt.*.o text data bss dec hex filename 86 0 0 86 56 missed-opt.manual.o 104 0 0 104 68 missed-opt.plain.o $ cat missed-opt.c ; echo EOF static int fd = -1; extern void dummy0(void); extern void dummy1(int); extern void setutent(void) __attribute__ ((__nothrow__ )); extern __typeof (setutent) setutent __asm__ ("" "__GI_setutent") __attribute__ ((visibility ("hidden"))); extern void getutent(void) __attribute__ ((__nothrow__ )); extern __typeof (getutent) getutent __asm__ ("" "__GI_getutent") __attribute__ ((visibility ("hidden"))); static void __setutent_unlocked(void) { if (fd < 0) { dummy0(); if (fd < 0) { dummy0(); if (fd < 0) return; } return; } dummy1(fd); } #ifndef OPTIMIZE_MANUALLY void setutent(void) { ((void)0); __setutent_unlocked(); ((void)0); } #else extern __typeof (__setutent_unlocked) setutent __attribute__ ((alias ("__setutent_unlocked"))); #endif extern __typeof (setutent) __EI_setutent __asm__("" "setutent"); extern __typeof (setutent) __EI_setutent __attribute__((alias ("" "__GI_setutent"))); static void __getutent_unlocked(void) { if (fd < 0) __setutent_unlocked(); } #ifndef OPTIMIZE_MANUALLY void getutent(void) { ((void)0); __getutent_unlocked(); ((void)0); } #else extern __typeof (__getutent_unlocked) getutent __attribute__ ((alias ("__getutent_unlocked"))); #endif extern __typeof (getutent) __EI_getutent __asm__("" "getutent"); extern __typeof (getutent) __EI_getutent __attribute__((alias ("" "__GI_getutent"))); EOF