Is there a GCC keyword to allow structure-reordering?

后端 未结 4 1356
灰色年华
灰色年华 2020-11-30 08:54

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 str

4条回答
  •  孤城傲影
    2020-11-30 09:37

    I think it is possible to reorganize/split elements of struct when you are compiling the whole program (lto mode, use -flto flag). In that case you have complete picture of the program, and for the symbols which do not escape it should be possible to reorder them for better cache behavior etc.

    In the gcc trunk this is under active development. This was presented in GNU cauldron 2015. You might want to try gcc trunk or the struct-reorg-branch.

    https://gcc.gnu.org/wiki/cauldron2015?action=AttachFile&do=view&target=Olga+Golovanevsky_+Memory+Layout+Optimizations+of+Structures+and+Objects.pdf

提交回复
热议问题