是否有一个GCC关键字,允许结构重新排序? [英] Is there a GCC keyword to allow structure-reordering?

查看:290
本文介绍了是否有一个GCC关键字,允许结构重新排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道为什么GCC不重新排序默认情况下,结构的成员,但我很少写code依靠结构的顺序,那么有没有什么办法可以标记我的结构是全自动重新排序?


解决方案

previous版本的GCC有<一个href=\"https://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Optimize-Options.html\"><$c$c>-fipa-struct-reorg选项​​允许结构重排 -fwhole程序 + -combine 模式。


  

      
  • -fipa-结构-REORG 结果
      进行结构优化重组,这种变化类似于C的结构布局,以更好地利用空间局部性。这种转变是情感包含结构的阵列方案。有两种编译模式:个人资料为基础的(启用了 -fprofile生成)或静态(使用内置的启发式)。要求 -fipa型逃生来提供这种转变的安全性。它的工作原理只有在整个程序模式,所以它需要 -fwhole程序 -combine 启用。结构被认为通过这种转变不会受到影响(见 - 参数结构-REORG-冷结构比=值)。

  •   

这是自GCC 4.8.x删除,由于在发行说明


  

该结构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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆