public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation
@ 2021-07-15  6:09 ashimida at linux dot alibaba.com
  2021-07-15  6:10 ` [Bug other/101459] " ashimida at linux dot alibaba.com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ashimida at linux dot alibaba.com @ 2021-07-15  6:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101459
           Summary: Mismatch in description of option "-falign-functions"
                    between source code and documentation
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ashimida at linux dot alibaba.com
  Target Milestone: ---

As descripted in online doc [1], -falign-functions is enable at levels -O2/-O3. 
But from source code and test result, this options is worked for all options
except -Os(such as -O0).
Is this an error in the documentation, or am I misunderstanding something?

FYI:
// ./gcc/varasm.c
void assemble_start_function (tree decl, const char *fnname)
{
  ......
  if (! DECL_USER_ALIGN (decl) 
          && align_functions.levels[0].log > align
      && optimize_function_for_speed_p (cfun))
  {
      int align_log = align_functions.levels[0].log;
      ......
      ASM_OUTPUT_ALIGN (asm_out_file, align_functions.levels[0].log);
  }
  ......
}

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

* [Bug other/101459] Mismatch in description of option "-falign-functions" between source code and documentation
  2021-07-15  6:09 [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation ashimida at linux dot alibaba.com
@ 2021-07-15  6:10 ` ashimida at linux dot alibaba.com
  2021-07-15  7:12 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ashimida at linux dot alibaba.com @ 2021-07-15  6:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from ashimida <ashimida at linux dot alibaba.com> ---
(In reply to ashimida from comment #0)
> As descripted in online doc [1], -falign-functions is enable at levels
> -O2/-O3. 
> But from source code and test result, this options is worked for all options
> except -Os(such as -O0).
> Is this an error in the documentation, or am I misunderstanding something?
> 
> FYI:
> // ./gcc/varasm.c
> void assemble_start_function (tree decl, const char *fnname)
> {
>   ......
>   if (! DECL_USER_ALIGN (decl) 
> 	  && align_functions.levels[0].log > align
>       && optimize_function_for_speed_p (cfun))
>   {
>       int align_log = align_functions.levels[0].log;
>       ......
>       ASM_OUTPUT_ALIGN (asm_out_file, align_functions.levels[0].log);
>   }
>   ......
> }

[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options

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

* [Bug other/101459] Mismatch in description of option "-falign-functions" between source code and documentation
  2021-07-15  6:09 [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation ashimida at linux dot alibaba.com
  2021-07-15  6:10 ` [Bug other/101459] " ashimida at linux dot alibaba.com
@ 2021-07-15  7:12 ` rguenth at gcc dot gnu.org
  2021-07-15  7:37 ` ashimida at linux dot alibaba.com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-15  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |documentation

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The flag, -falign-functions is only enabled at -O2+ (but not -Os), but the
actual alignment is recorded in the 'align_functions' data which is only
populated when -falign-functions is specified so I think it works as
documented.

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

* [Bug other/101459] Mismatch in description of option "-falign-functions" between source code and documentation
  2021-07-15  6:09 [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation ashimida at linux dot alibaba.com
  2021-07-15  6:10 ` [Bug other/101459] " ashimida at linux dot alibaba.com
  2021-07-15  7:12 ` rguenth at gcc dot gnu.org
@ 2021-07-15  7:37 ` ashimida at linux dot alibaba.com
  2021-07-16  1:03 ` pinskia at gcc dot gnu.org
  2021-07-16  1:28 ` ashimida at linux dot alibaba.com
  4 siblings, 0 replies; 6+ messages in thread
From: ashimida at linux dot alibaba.com @ 2021-07-15  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from ashimida <ashimida at linux dot alibaba.com> ---
(In reply to Richard Biener from comment #2)
> The flag, -falign-functions is only enabled at -O2+ (but not -Os), but the
> actual alignment is recorded in the 'align_functions' data which is only
> populated when -falign-functions is specified so I think it works as
> documented.

I tested this option in gcc 7.5.0 and 9.2.0, with the source code:

int func1(void)                                                                 
{
    return 0;
}

int func2(void)
{
    return 0;
}

int main (void)
{
    return 1;
}

and the result is like:
ashimida@ubuntu:~/test1$ aarch64-linux-gnu-gcc -falign-functions=128 -O0 test.c
-o test
ashimida@ubuntu:~/test1$ readelf -s test|grep fun
    63: 0000000000000780     8 FUNC    GLOBAL DEFAULT   13 func1
    78: 0000000000000800     8 FUNC    GLOBAL DEFAULT   13 func2
ashimida@ubuntu:~/test1$ aarch64-linux-gnu-gcc -O0 test.c -o test
ashimida@ubuntu:~/test1$ readelf -s test|grep fun
    63: 00000000000006e4     8 FUNC    GLOBAL DEFAULT   13 func1
    78: 00000000000006ec     8 FUNC    GLOBAL DEFAULT   13 func2

so I think this flag is also worked at -O0

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

* [Bug other/101459] Mismatch in description of option "-falign-functions" between source code and documentation
  2021-07-15  6:09 [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation ashimida at linux dot alibaba.com
                   ` (2 preceding siblings ...)
  2021-07-15  7:37 ` ashimida at linux dot alibaba.com
@ 2021-07-16  1:03 ` pinskia at gcc dot gnu.org
  2021-07-16  1:28 ` ashimida at linux dot alibaba.com
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-16  1:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to ashimida from comment #3)
> (In reply to Richard Biener from comment #2)
> > The flag, -falign-functions is only enabled at -O2+ (but not -Os), but the
> > actual alignment is recorded in the 'align_functions' data which is only
> > populated when -falign-functions is specified so I think it works as
> > documented.
> 
> so I think this flag is also worked at -O0

I think you are misunderstanding the documentation.  The documentation is
saying it is enabled by default at -O2 and above (but not -Os); not that it
will only work at -O2 and above.

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

* [Bug other/101459] Mismatch in description of option "-falign-functions" between source code and documentation
  2021-07-15  6:09 [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation ashimida at linux dot alibaba.com
                   ` (3 preceding siblings ...)
  2021-07-16  1:03 ` pinskia at gcc dot gnu.org
@ 2021-07-16  1:28 ` ashimida at linux dot alibaba.com
  4 siblings, 0 replies; 6+ messages in thread
From: ashimida at linux dot alibaba.com @ 2021-07-16  1:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from ashimida <ashimida at linux dot alibaba.com> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to ashimida from comment #3)
> > (In reply to Richard Biener from comment #2)
> > > The flag, -falign-functions is only enabled at -O2+ (but not -Os), but the
> > > actual alignment is recorded in the 'align_functions' data which is only
> > > populated when -falign-functions is specified so I think it works as
> > > documented.
> > 
> > so I think this flag is also worked at -O0
> 
> I think you are misunderstanding the documentation.  The documentation is
> saying it is enabled by default at -O2 and above (but not -Os); not that it
> will only work at -O2 and above.

okey, now I understand, I have misunderstood this option, thank you very much!

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

end of thread, other threads:[~2021-07-16  1:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15  6:09 [Bug other/101459] New: Mismatch in description of option "-falign-functions" between source code and documentation ashimida at linux dot alibaba.com
2021-07-15  6:10 ` [Bug other/101459] " ashimida at linux dot alibaba.com
2021-07-15  7:12 ` rguenth at gcc dot gnu.org
2021-07-15  7:37 ` ashimida at linux dot alibaba.com
2021-07-16  1:03 ` pinskia at gcc dot gnu.org
2021-07-16  1:28 ` ashimida at linux dot alibaba.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).