使用该选项控制内存空间布局优化系列优化。
1 2 3 4 5 | struct S { type1 field1; // Never read in whole program type2 field2; }; |
转化为
1 2 3 4 | struct S.layout { type2 field2; }; |
将以下结构体:
1 2 3 4 5 | struct S { struct S* field1; type2 field2; }; |
转化为:
1 2 3 4 5 | struct S.layout { uint32_t field1.pc; type2 field2; }; |
该等级支持结构体数组大小在编译期间未知的场景,用户需自行确认压缩等级合法,不同等级支持的最大结构体数组大小如下表所示。
指针大小 |
最大支持数组范围 |
---|---|
8 |
254(0xff-1) |
16 |
65534(0xffff-1) |
32 |
4294967294(0xffffffff-1) |
1 2 3 4 5 | struct S { long a, int b, short c }; |
在选项中加入:
1 | -O3 -flto -flto-partition=one -fipa-struct-reorg=n |
其中n取值范围为[0,6]。
-fipa-struct-reorg=n选项,需要在-O3 -flto -flto-partition=one全局同时开启的基础上才使能。