https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112717
Bug ID: 112717 Summary: .gcda profiles compatibility guarantees between GCC versions Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: zamazan4ik at tut dot by CC: marxin at gcc dot gnu.org Target Milestone: --- Hi. I have several questions regarding .gcda profiles re-usage between GCC versions for Profile-Guided Optimization (PGO) purposes. The first question goes about forward and backward guarantees .gcda profiles. I didn't find related information in the GCC documentation. Are there guarantees in this area? Like "it's guaranteed that .gcda profiles from GCC version N will be always readable by GCC version N+1", where N is a minor/major GCC version. For us it's an important question since we are thinking about caching .gcda profiles in storage so PGO profiles can be reused later probably with a newer compiler. This goes in another direction too in the case if we generated the PGO profile with GCC 10 and some time later decided to revert the compiler to GCC 9. If there are some guarantees in this area, would be great to see them documented somewhere in the documentation (probably in a place like https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html). The second question is about PGO profiles reusability between GCC versions. As far as I understand, PGO profiles track some "counters" about the code. Possibly these counters can rely somehow on the performed by GCC optimizations (it's just my guess). Let's imagine that GCC 11 added more optimization passes that affect somehow generated code (e.g. much more aggressive inlining compared to GCC 10). In this case, probably, PGO profiles from GCC 10 wouldn't be useful anymore and we will need to regenerate them once again but with GCC 11. Is this scenario real? If yes, are there ways to mitigate it somehow? For LLVM I have the same questions that are discussed here: https://discourse.llvm.org/t/profile-guided-optimization-pgo-related-questions-and-suggestions/75232 . As far as I understand, GCC also implements PGO on something like "IR" (don't know how it's called properly in GCC - "Generic" or "GIMPLE"?), so probably some answers from LLVM would be applicable to GCC as well.