-fipa-struct-reorg=n
This option is used to control the memory space layout optimization series.
- -fipa-struct-reorg=0 indicates that no optimization is enabled.
- -fipa-struct-reorg=1 enables structure splitting and structure array optimization, which is equivalent to using -fipa-struct-reorg.
- -fipa-struct-reorg=2 adds the structure member rearrangement -fipa-reorder-fields based on -fipa-struct-reorg=1.
- -fipa-struct-reorg=3 adds redundant structure member removal based on -fipa-struct-reorg=2. Redundant structure members that are never used are removed from the structure. Change the following structure:
1 2 3 4 5
struct S { type1 field1; // Never read in whole program type2 field2; };
To:
1 2 3 4
struct S.layout { type2 field2; };
- -fipa-struct-reorg=4 adds the security structure pointer compression based on -fipa-struct-reorg=3.Structure pointer compression is used to compress the structure pointers in the structure domain members to 8, 16, or 32 bits, reducing the memory occupied by the structure and reducing the bandwidth pressure when data is read from or written to the memory, thereby improving performance.
- Secure structure pointer compression supports only the scenario where the structure array size is known during compilation.
- --param compressed-pointer-size=[8,16,32] is used to control the size of a compression object. The default value is 32.
Change the following structure:
1 2 3 4 5
struct S { struct S* field1; type2 field2; };
To:
1 2 3 4 5
struct S.layout { uint32_t field1.pc; type2 field2; };
- -fipa-struct-reorg=5 adds an application scenario of structure pointer compression based on -fipa-struct-reorg=4.
This level supports the scenario where the structure array size is unknown during compilation. You need to confirm that the compression level is valid. The following table lists the maximum structure array sizes supported by different levels.
Pointer Size
Maximum Array Size
8
254 (0xff–1)
16
65534 (0xffff–1)
32
4294967294 (0xffffffff–1)
- -fipa-struct-reorg=6 adds the structure array semi-relayout based on -fipa-struct-reorg=5.Semi-relayout is used to pack and rearrange structure members in a structure array within a certain range to improve the data spatial locality and improve the performance.
- --param semi-relayout-level=[11,12,13,14,15] is used to control the semi-relayout rearrangement scale. The default value is 13. That is, semi-relayout rearranges every 1024 structures as a group. If the number of structures is less than 1024, padding is used. The calculation method is (1 << semi-relayout-level) / 8.
- Convert the structure array layout in the memory from consecutive structures to structures shown in the following figure.Figure 1 Semi-relayout optimization principle

1 2 3 4 5
struct S { long a, int b, short c };
Usage
Add the following content to the option:
1 | -O3 -flto -flto-partition=one -fipa-struct-reorg=n |
The value range of n is [0,6].
The-fipa-struct-reorg=n option can be used only when -O3 -flto -flto-partition=one is enabled globally.
Parent topic: Static Compilation Optimization