What information does GCC Profile Guided Optimization (PGO) collect and which optimizations use it?

前端 未结 2 1507
滥情空心
滥情空心 2020-12-04 23:53

Which information does GCC collect when I enable -fprofile-generate and which optimization does in fact uses the collected information (when setting the -

2条回答
  •  盖世英雄少女心
    2020-12-05 00:14

    "What Every Programmer Should Know About Memory" by Ulrich Drepper https://people.freebsd.org/~lstewart/articles/cpumemory.pdf http://www.akkadia.org/drepper/cpumemory.pdf

    In section 7.4

    • compilation with --profile-generate generates .gcno file for each object file. (the same file that is used for gcov coverage reports)
    • then you must run a few tests, during runtime it records coverage data into .gcda files
    • recompile with --profile-use : it will gather the coverage data and infer if an branch is likely (__builtin_expect( .. , 1 ) or unlikely (__builtin_expect( .. , 0)

    The result should run faster as it should be better at prefetching code into the processor instruction cache.

提交回复
热议问题