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
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