From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26963 invoked by alias); 10 May 2002 18:46:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26925 invoked by uid 71); 10 May 2002 18:46:01 -0000 Resent-Date: 10 May 2002 18:46:01 -0000 Resent-Message-ID: <20020510184601.26924.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, obrien@FreeBSD.org, jhb@FreeBSD.org Received:(qmail 24235 invoked from network); 10 May 2002 18:42:51 -0000 Received: from unknown (HELO dragon.nuxi.com) (66.92.13.169) by sources.redhat.com with SMTP; 10 May 2002 18:42:51 -0000 Received: from dragon.nuxi.com (obrien@localhost [127.0.0.1]) by dragon.nuxi.com (8.12.3/8.12.2) with ESMTP id g4AIgoev083544; Fri, 10 May 2002 11:42:50 -0700 (PDT) (envelope-from obrien@dragon.nuxi.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.12.3/8.12.3/Submit) id g4AIgo1f083543; Fri, 10 May 2002 11:42:50 -0700 (PDT) Message-Id:<200205101842.g4AIgo1f083543@dragon.nuxi.com> Date: Fri, 10 May 2002 11:46:00 -0000 From: obrien@FreeBSD.org Reply-To: obrien@FreeBSD.org, jhb@FreeBSD.org To: gcc-gnats@gcc.gnu.org Cc: John Baldwin X-Send-Pr-Version:3.113 Subject: optimization/6627: -fno-align-functions regression from 2.95 X-SW-Source: 2002-05/txt/msg00303.txt.bz2 List-Id: >Number: 6627 >Category: optimization >Synopsis: -fno-align-functions regression from 2.95 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Fri May 10 11:46:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: David O'Brien >Release: 3.1 20020509 (prerelease) [FreeBSD] >Organization: The FreeBSD Project >Environment: System: FreeBSD dragon.nuxi.com 5.0-CURRENT FreeBSD 5.0-CURRENT #261: Mon May 6 11:39:49 PDT 2002 rootk@dragon.nuxi.com:/FBSD/src/sys/i386/compile/DRAGON i386 host: i386-portbld-freebsd5.0 build: i386-portbld-freebsd5.0 target: i386-portbld-freebsd5.0 configured with: ./..//gcc-20020429/configure --disable-nls --with-gnu-as --with-gnu-ld --with-gxx-include-dir=/opt/gcc31.2002-04-29/lib/gcc-lib/i386-portbld-freebsd5.0/3.1/include/g++ --disable-libgcj --disable-shared --prefix=/opt/gcc31.2002-04-29 i386-portbld-freebsd5.0 >Description: from http://gcc.gnu.org/ml/gcc-bugs/2002-05/msg00372.html We are currently trying to change the system compiler in FreeBSD over to gcc 3.1.x. Some of the C code we compile is in the bootstrap where space is a real premium, thus we want to avoid as much padding as possible. Since it's just boot code that isn't executed all that often the performance hit from making the code more compact (i.e. if it's misaligned) is much less important than the space taken up by padding. The problem we are seeing is that -fno-align-functions doesn't seem to actually be disabling function alignment (and possibly similar for the other -fno-align-foo parameters). Using the program below, this is what the current system compiler (2.95.4 turns out: $ cc -v Using builtin specs. gcc version 2.95.4 20020320 [FreeBSD] $ cc -Os -malign-functions=0 test.c -c $ objdump -d test.o test.o: file format elf32-i386 Disassembly of section .text: 00000000 : 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: c9 leave 4: c3 ret 00000005 : 5: 55 push %ebp 6: 89 e5 mov %esp,%ebp 8: c9 leave 9: c3 ret a: 89 f6 mov %esi,%esi Note starts at offset 05 right after . This is what a CVS version of gcc 3.1 turns out: $ gcc31 -v Reading specs from /usr/local/lib/gcc-lib/i386-portbld-freebsd5.0/3.1/specs Configured with: ./..//gcc-20020429/configure --disable-nls --with-gnu-as --with-gnu-ld --with-gxx-include-dir=/usr/local/lib/gcc-lib/i386-portbld-freebsd5.0/3.1/includ e/g++ --disable-libgcj --disable-shared --prefix=/usr/local i386-portbld-freebsd5.0 Thread model: posix gcc version 3.1 20020429 (prerelease) [FreeBSD] $ gcc31 -Os -malign-functions=0 -c test.c cc1: warning: -malign-functions is obsolete, use -falign-functions $ objdump -d test.o test.o: file format elf32-i386 Disassembly of section .text: 00000000 : 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: c9 leave 4: c3 ret 5: 90 nop 00000006 : 6: 55 push %ebp 7: 89 e5 mov %esp,%ebp 9: c9 leave a: c3 ret b: 90 nop Note the extra 'nop' after now to force to be aligned. If I use '-fno-align-functions' in place of '-malign-functions=0' above, I get the same result. Now a few extra nop's after each function isn't going to add but so much "bloat" but we have seen a 7k program go from 128 bytes to spare to being 64 bytes too large, which is a difference of 244 bytes. As far as I can tell, the difference in size is due to alignment padding for functions, labels, loops, etc. >How-To-Repeat: void foo(void); void bar(void); void foo(void) { } void bar(void) { } gcc295 -Os -malign-functions=0 -c test.c gcc31 -Os -malign-functions=0 -c test.c >Fix: >Release-Note: >Audit-Trail: >Unformatted: