是否有一个GCC关键字,允许结构重新排序? [英] Is there a GCC keyword to allow structure-reordering?
问题描述
我知道为什么GCC不重新排序默认情况下,结构的成员,但我很少写code依靠结构的顺序,那么有没有什么办法可以标记我的结构是全自动重新排序?
previous版本的GCC有<一个href=\"https://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html\"><$c$c>-fipa-struct-reorg$c$c>选项允许结构重排 -fwhole程序
+ -combine
模式。
-fipa-结构-REORG
结果
进行结构优化重组,这种变化类似于C的结构布局,以更好地利用空间局部性。这种转变是情感包含结构的阵列方案。有两种编译模式:个人资料为基础的(启用了-fprofile生成
)或静态(使用内置的启发式)。要求-fipa型逃生
来提供这种转变的安全性。它的工作原理只有在整个程序模式,所以它需要-fwhole程序
和-combine
启用。结构被认为冷
通过这种转变不会受到影响(见- 参数结构-REORG-冷结构比=值
)。
块引用>这是自GCC 4.8.x删除,由于在发行说明 以下原因p>
该结构REORG和REORG矩阵优化(命令行选项
-fipa-结构-REORG
和-fipa矩阵-REORG
)已被删除。他们并不总是正确,也没带链接时优化(LTO)工作,因此只适用于由单个翻译单元的节目。
块引用>但是你仍然可以尝试
结构-REORG分支
在 GCC SVN 的在你自己的风险,因为它仍处于积极发展。I know why GCC doesn't re-order members of a structure by default, but I seldom write code that relies on the order of the structure, so is there some way I can flag my structures to be automaticly reordered?
解决方案Previous GCC versions have the
-fipa-struct-reorg
option to allow structure reordering in-fwhole-program
+-combine
mode.
-fipa-struct-reorg
Perform structure reorganization optimization, that change C-like structures layout in order to better utilize spatial locality. This transformation is affective for programs containing arrays of structures. Available in two compilation modes: profile-based (enabled with-fprofile-generate
) or static (which uses built-in heuristics). Require-fipa-type-escape
to provide the safety of this transformation. It works only in whole program mode, so it requires-fwhole-program
and-combine
to be enabled. Structures considered'cold'
by this transformation are not affected (see--param struct-reorg-cold-struct-ratio=value
).It was removed since GCC 4.8.x due to the below reasons in the release note
The struct reorg and matrix reorg optimizations (command-line options
-fipa-struct-reorg
and-fipa-matrix-reorg
) have been removed. They did not always work correctly, nor did they work with link-time optimization (LTO), hence were only applicable to programs consisting of a single translation unit.However you can still try the
struct-reorg-branch
on GCC SVN out on your own risk as it's still in active development.这篇关于是否有一个GCC关键字,允许结构重新排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!