https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120229
Bug ID: 120229
Summary: [GCOV] AutoFDO cannot distinguish privatized functions
of different LTO partitions
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: dhruvc at nvidia dot com
Target Milestone: ---
The GCOV file format as used by the AutoFDO tools does not track source file
information for functions. This means that when resolving functions by
stripping
the suffixes from the profile information, the auto-profile pass ends up
using only the first instance of a function for all `function_instance's with
the same base name.
Example:
=== a.cpp
__attribute__((noinline)) static void effect_1() {}
void global() { effect_1(); }
===
=== b.cpp
__attribute__((noinline)) static void effect_1() {}
extern void global();
int main() {
/* ... for-loop ... */
global();
effect_1();
/* } */
}
===
This example will create `effect_1.lto_priv.0' and `effect_1.lto_priv.1' if
both functions are assigned to the same LTO partition. If the indices in the
string table are 1 and 2, auto-profile will track these as: 1 -> `effect_1',
2 -> `effect_1' after stripping the suffixes. When annotating these functions,
it will end up picking 1 -> `effect_1' for both of them, using the incorrect
profile information for the second function.
The solution for this problem is to track the source-file name in GCOV, by
pairing each function-name entry with the name of the source file it came from.
TODO: The downside to this solution is that different directories having source
files with the same name containing static functions with the same name,
assigned to the same LTO partition will exhibit the old, broken behaviour.
We are currently working on a prototype patch that fixes this bug.