https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88231

            Bug ID: 88231
           Summary: aligned functions laid down inefficiently
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

While testing attribute aligned on functions I noticed that GCC doesn't seem to
take advantage of function alignment to optimize space in the emitted assembly.
 For instance, emitting the following functions in the order f8, f1, f2 would
reduce their size overall size from 10 bytes to 3.

$ cat t.c && gcc -Os -c -Wall t.c && objdump -d t.o
__attribute__ ((aligned (1))) void f1 (void) { }
__attribute__ ((aligned (8))) void f8 (void) { }
__attribute__ ((aligned (2))) void f2 (void) { }

t.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <f1>:
   0:   c3                      retq   
   1:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)   ;; wasted space

0000000000000008 <f8>:
   8:   c3                      retq   
   9:   90                      nop   ;; wasted space

000000000000000a <f2>:
   a:   c3                      retq

Reply via email to