On Thu, 26 May 2022, Yitschak, Yehuda via Gcc-help wrote: > Hello > > I am learned about GCC FDO capabilities but AFAICT it doesn't effect the > function layout which the linker generates > My intention is to use the feedback data to create an optimal function layout > to minimize I-cache misses. > Meaning to group the most frequently accessed functions together and perhaps > even order them to utilize cache prefetch better. > > Is there anyway to achieve that in GCC ? Yes. The compiler can select some order of functions, and place functions in separate sections named .text.sorted.NNNN, and then the linker can emit the sections in desired order (new Binutils linker handles .text.sorted.N automatically, for older linkers you can pass --sort-section=name). As you probably know, coming up with a good reordering is the hard part. There is an experimental GCC patch that implements C3 reordering algorithm: https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg01142.html Alexander