From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10304 invoked by alias); 13 Oct 2014 18:49:06 -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 10236 invoked by uid 48); 13 Oct 2014 18:49:01 -0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/63527] New: [5 Regression] -fPIC generates more instructions Date: Mon, 13 Oct 2014 18:49:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com 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 bug_severity priority component assigned_to reporter cc cf_gcctarget 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: 2014-10/txt/msg00987.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63527 Bug ID: 63527 Summary: [5 Regression] -fPIC generates more instructions Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: evstupac at gmail dot com Target: i686-linux On Linux/x86, r216154 generates more instructions with -O2 -fPIC for ---- struct cache_file { char magic[sizeof "ld.so-1.7.0" - 1]; unsigned int nlibs; }; typedef unsigned int size_t; size_t cachesize __attribute__ ((visibility ("hidden"))); struct cache_file *cache __attribute__ ((visibility ("hidden"))); extern int __munmap (void *__addr, size_t __len); void _dl_unload_cache (void) { if (cache != ((void *)0) && cache != (struct cache_file *) -1) { __munmap (cache, cachesize); cache = ((void *)0) ; } } ---- r216153 generates --- .text .LHOTB0: .p2align 4,,15 .globl _dl_unload_cache .type _dl_unload_cache, @function _dl_unload_cache: pushl %ebx call __x86.get_pc_thunk.bx addl $_GLOBAL_OFFSET_TABLE_, %ebx subl $8, %esp movl cache@GOTOFF(%ebx), %eax leal -1(%eax), %edx cmpl $-3, %edx ja .L1 subl $8, %esp pushl cachesize@GOTOFF(%ebx) pushl %eax call __munmap@PLT movl $0, cache@GOTOFF(%ebx) addl $16, %esp .L1: addl $8, %esp popl %ebx ret .size _dl_unload_cache, .-_dl_unload_cache .section .text.unlikely .LCOLDE0: .text .LHOTE0: .hidden cache .comm cache,4,4 .hidden cachesize .comm cachesize,4,4 .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat .globl __x86.get_pc_thunk.bx .hidden __x86.get_pc_thunk.bx .type __x86.get_pc_thunk.bx, @function __x86.get_pc_thunk.bx: movl (%esp), %ebx ret --- r216154 generates -- .text .LHOTB0: .p2align 4,,15 .globl _dl_unload_cache .type _dl_unload_cache, @function _dl_unload_cache: pushl %esi pushl %ebx call __x86.get_pc_thunk.si addl $_GLOBAL_OFFSET_TABLE_, %esi subl $4, %esp movl cache@GOTOFF(%esi), %eax leal -1(%eax), %edx cmpl $-3, %edx ja .L1 subl $8, %esp pushl cachesize@GOTOFF(%esi) movl %esi, %ebx pushl %eax call __munmap@PLT movl $0, cache@GOTOFF(%esi) addl $16, %esp .L1: addl $4, %esp popl %ebx popl %esi ret .size _dl_unload_cache, .-_dl_unload_cache .section .text.unlikely .LCOLDE0: .text .LHOTE0: .hidden cache .comm cache,4,4 .hidden cachesize .comm cachesize,4,4 .section .text.__x86.get_pc_thunk.si,"axG",@progbits,__x86.get_pc_thunk.si,comdat .globl __x86.get_pc_thunk.si .hidden __x86.get_pc_thunk.si .type __x86.get_pc_thunk.si, @function __x86.get_pc_thunk.si: movl (%esp), %esi ret -- Why doesn't r216154 simply use %ebx to access cache, cachesize and __munmap?