llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.9k stars 11.94k forks source link

[gcov] Ability to map gcda file paths #54670

Open vit9696 opened 2 years ago

vit9696 commented 2 years ago

When compiling code with -fprofile-arcs clang encodes full .gcda file path based on the object file path. In some cases this is infeasible, as the compilation directory may have extra long prefix, which is not practical to store on embedded targets.

To avoid this issue we would like to replace this prefix with a custom value by extending -fcoverage-prefix-map option. There is a similar issue in gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105063), where we were able to reach a certain level of agreement. Will clang follow?

vit9696 commented 2 years ago

CC @petrhosek, @keith

keith commented 2 years ago

IIRC @petrhosek had some thoughts when we introduced -fcoverage-prefix-map about whether or not it should apply to all profiles (originally it was named -fprofile-prefix-map and we changed the name since it didn't end up that way). This seems like a reasonable thing to me, alternatively it could be only added to -ffile-prefix-map if that covered most cases.

petrhosek commented 2 years ago

We used the name -fcoverage-prefix-map to make it clear that it only only applies to Clang coverage mapping and not to profile instrumentation (which is shared by both coverage and PGO). Since the feature you're proposing is specific to gcov, using a separate flag that matches the name used by GCC would be preferable to me.

vit9696 commented 2 years ago

Marxin from GCC suggested to keep using -fprofile-prefix-map, and there is a working patch in the bugzilla. Can we follow this in clang? I guess I can work on the patch if the design is settled.

vit9696 commented 2 years ago

Posted initial version of the patch on phabricator: https://reviews.llvm.org/D124767

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-codegen