[all-commits] [llvm/llvm-project] d515b8: [Driver][gcov] Derive .gcno .gcda file names from ...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed May 17 00:43:13 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d515b8125364ef85fb100f1430b2174ed816cc18
https://github.com/llvm/llvm-project/commit/d515b8125364ef85fb100f1430b2174ed816cc18
Author: Fangrui Song <i at maskray.me>
Date: 2023-05-17 (Wed, 17 May 2023)
Changed paths:
M clang/lib/Driver/ToolChains/Clang.cpp
M clang/test/Driver/coverage.c
M clang/test/Driver/working-directory.c
Log Message:
-----------
[Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir
Resolve a FIXME.
When -ftest-profile, -fprofile-arcs, or --coverage is specified and the
driver performs both compilation and linking phases, derive the .gcno &
.gcda file names from -o and -dumpdir.
`clang --coverage d/a.c d/b.c -o e/x && e/x` will now emit
`e/x-[ab].gc{no,da}` like GCC.
For -fprofile-dir=, we make the deliberate decision to not mangle the
input filename if relative.
The following script demonstrates the .gcno and .gcda filenames.
```
PATH=/tmp/Rel/bin:$PATH # adapt according to your build directory
mkdir -p d e f
echo 'int main() {}' > d/a.c
echo > d/b.c
a() { rm $@ || exit 1; }
clang --coverage d/a.c d/b.c && ./a.out
a a-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x -dumpdir f/ && e/x
a f/[ab].gc{no,da}
clang --coverage -fprofile-dir=f d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gcno f/e/x-[ab].gcda
clang -c --coverage d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gc{no,da}
clang -c --coverage -fprofile-dir=f d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gcno f/[ab].gcda
clang -c --coverage d/a.c -o e/xa.o && clang --coverage e/xa.o && ./a.out
a e/xa.gc{no,da}
clang -c --coverage d/a.c -o e/xa.o -dumpdir f/g && clang --coverage e/xa.o && ./a.out
a f/ga.gc{no,da}
```
The gcov code accidentally claims -c and -S, so -fsyntax-only -c/-S and
-E -c/-S don't leave to a -Wunused-command-line-argument warning. Keep
the unintended code for now.
More information about the All-commits
mailing list