See upstream discussion about this topic:
This is the new solution I am proposing. It is basically an enhancement of Solution-1 with most of the weakness resolved. The difference with Solution-1 is
- Function name symbols are emitted into the symbol table as weak externs. They don't occupy any space at runtime and can be easily stripped.
- -fcoverage-mapping does not need special handling -- it automatically benefit from the same size saving.
- llvm-cov is changed to read symbol info from the symtab instead of reading them from the name section data
- llvm-profdata is enhanced to take a binary as input and dump profile with names attached. Function filtering is fully supported (option can also be introduced to force dumping names into binary and profile data, so that llvm-profdata use case is not changed at all).
Pros:
- All the pros from Solution-1
- Size savings for coverage-mapping case
Cons:
Format change is required for profile data and coverage mapping.