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

Zhaohaifeng <zhaohaifeng4 at huawei dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zhaohaifeng4 at huawei dot com

--- Comment #2 from Zhaohaifeng <zhaohaifeng4 at huawei dot com> ---
(In reply to Andrew Pinski from comment #1)
> ```
> Rec_Pointer     Ptr_Glob,
>                 Next_Ptr_Glob;
> int             Int_Glob;
> Boolean         Bool_Glob;
> char            Ch_1_Glob,
>                 Ch_2_Glob;
> int             Arr_1_Glob [50];
> int             Arr_2_Glob [50] [50];
> ```
> 
> Maybe the order of these changed in the layout of the final executable.
> In the case of -fcommon, the layout of these are handled by the linker while
> with -fno-common, they are handled by compiler into the assembly into the
> specific section (and then the sections are combined/laid out by the linker).
> 
> So maybe look at the linker map and compare it to what GCC does with
> -fno-common in the .s file.

Some test results:
1. Using gcc 10.3 the variables are arranged from the last Dhrystone_Per_Second
to the first Ptr_Glob, both in .s file and the final binary. If we change the
sequence of the variables in the source code, the sequence in assembly and
binary is also changed as in source code.

2. Using gcc 8.5 the variables are arranged specially both in assembly and
final binary,If the variable sequence is changed in the source code, the
sequence in assembly and binary is NOT changed.

Do we expect the fcommon option do some performance optimizatin? How does
fcommon arrange the variables?

Reply via email to