public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/30004]  New: overzealous alignment of structure - 32 bytes (not bits!)
@ 2006-11-27 22:51 vda dot linux at googlemail dot com
  2006-11-27 22:57 ` [Bug rtl-optimization/30004] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vda dot linux at googlemail dot com @ 2006-11-27 22:51 UTC (permalink / raw)
  To: gcc-bugs

Hello. I am a maintainer of busybox project. One of our goals is to optimize
our code for size. The following testcase was derived from busybox source:

struct client_config_t {
        char foreground;
        char quit_after_lease;
        char release_on_quit;
        char abort_if_no_lease;
        char *interface;
        char *script;
        char *clientid;
        char *fqdn;
        int retries;
        int timeout;
        char arp[6];
};
struct client_config_t udhcp_client_config1;
struct client_config_t client_config2 = {
        /* Default options. */
        .abort_if_no_lease = 0,
        .foreground = 0,
        .quit_after_lease = 0,
        .release_on_quit = 0,
        .interface = "eth0",
        .script = "/share/udhcpc/default.script",
        .clientid = 0,
        .fqdn = 0,
        .retries = 3,
        .timeout = 3,
        .arp = "\0\0\0\0\0\0",          /* appease gcc-3.0 */
};
int udhcpc_main(int argc, char *argv[])
{
        udhcp_client_config1.interface = "eth0";
        udhcp_client_config1.script = "/share/udhcpc/default.script";
        udhcp_client_config1.retries = udhcp_client_config1.timeout = 3;
        return 0;
}

Even when compiled with optimisation for size (gcc -Os -S -fomit-frame-pointer
dhcpc.c), both data- and bss-placed structures are aligned to 32 _bytes_.
The structs are itself only _36 bytes_ large! When a lot of structures from
different .o modules are combined into final executable, we waste a lot of
space (on average, 15.5 bytes per structure):

        .file   "dhcpc.c"
        .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
        .string "eth0"
.LC1:
        .string "/share/udhcpc/default.script"
        .text
.globl udhcpc_main
        .type   udhcpc_main, @function
udhcpc_main:
        movl    $.LC0, udhcp_client_config1+4
        movl    $.LC1, udhcp_client_config1+8
        movl    $3, udhcp_client_config1+24
        movl    $3, udhcp_client_config1+20
        xorl    %eax, %eax
        ret
        .size   udhcpc_main, .-udhcpc_main
.globl client_config2
        .data
        .align 32    <---------------------HERE
        .type   client_config2, @object
        .size   client_config2, 36
client_config2:
        .byte   0
        .byte   0
        .byte   0
        .byte   0
        .long   .LC0
        .long   .LC1
        .long   0
        .long   0
        .long   3
        .long   3
        .string ""
        .string ""
        .string ""
        .string ""
        .string ""
        .string ""
        .zero   2
        .comm   udhcp_client_config1,36,32  <---- HERE
        .ident  "GCC: (GNU) 4.1.1"
        .section        .note.GNU-stack,"",@progbits

Is it possible to instruct gcc to use smaller alignment?

BTW, is there any progress on bug 22158 (also related to data alignment)? I
have a patch there...


-- 
           Summary: overzealous alignment of structure - 32 bytes (not
                    bits!)
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vda dot linux at googlemail dot com
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30004


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rtl-optimization/30004] overzealous alignment of structure - 32 bytes (not bits!)
  2006-11-27 22:51 [Bug rtl-optimization/30004] New: overzealous alignment of structure - 32 bytes (not bits!) vda dot linux at googlemail dot com
@ 2006-11-27 22:57 ` pinskia at gcc dot gnu dot org
  2006-11-27 22:59 ` pinskia at gcc dot gnu dot org
  2006-11-27 23:03 ` vda dot linux at googlemail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-11-27 22:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-11-27 22:57 -------
I think this was fixed by:
2006-01-10  Jan Beulich  <jbeulich@novell.com>

        * config/i386/i386.c (ix86_data_alignment): Don't force alignment to
        256 bits when optimize_size.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30004


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rtl-optimization/30004] overzealous alignment of structure - 32 bytes (not bits!)
  2006-11-27 22:51 [Bug rtl-optimization/30004] New: overzealous alignment of structure - 32 bytes (not bits!) vda dot linux at googlemail dot com
  2006-11-27 22:57 ` [Bug rtl-optimization/30004] " pinskia at gcc dot gnu dot org
@ 2006-11-27 22:59 ` pinskia at gcc dot gnu dot org
  2006-11-27 23:03 ` vda dot linux at googlemail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-11-27 22:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-11-27 22:59 -------
Yes it was fixed:
        .comm   udhcp_client_config1,36,4

.....

        .align 4
        .type   client_config2, @object
        .size   client_config2, 36
client_config2:


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30004


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rtl-optimization/30004] overzealous alignment of structure - 32 bytes (not bits!)
  2006-11-27 22:51 [Bug rtl-optimization/30004] New: overzealous alignment of structure - 32 bytes (not bits!) vda dot linux at googlemail dot com
  2006-11-27 22:57 ` [Bug rtl-optimization/30004] " pinskia at gcc dot gnu dot org
  2006-11-27 22:59 ` pinskia at gcc dot gnu dot org
@ 2006-11-27 23:03 ` vda dot linux at googlemail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: vda dot linux at googlemail dot com @ 2006-11-27 23:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from vda dot linux at googlemail dot com  2006-11-27 23:03 -------
Super! Thanks!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30004


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-27 23:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-27 22:51 [Bug rtl-optimization/30004] New: overzealous alignment of structure - 32 bytes (not bits!) vda dot linux at googlemail dot com
2006-11-27 22:57 ` [Bug rtl-optimization/30004] " pinskia at gcc dot gnu dot org
2006-11-27 22:59 ` pinskia at gcc dot gnu dot org
2006-11-27 23:03 ` vda dot linux at googlemail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).