I’m trying to get code coverage to work on our project using clang-cl. Unfortunately, due to legacy, the amount of code that is taken along in the test exes is quite large.
Compiling with only -fprofile-instr-generate -fcoverage-mapping
gives us a profraw file of 4GB after the unit test has ran.
I did find the -fprofile-list=cov.list
option and managed to prune the symbols by a lot already. Currently the file is only 2GB. (taking around 10 seconds to write)
With the following, I am able to get some idea of what is in the file:
llvm-profdata.exe show --all-functions .\default.profraw -o default.profraw.allfunc
undname.exe default.profraw.allfunc > default.profraw.symbols
the allfunc file contains:
??$?0AEA_K@?$_Optional_destruct_base@_K$00@std@@QEAA@Uin_place_t@1@AEA_K@Z:
Hash: 0x0000000000000000
Counters: 1
Function count: 1023
or unmangled
public: __cdecl std::_Optional_destruct_base<unsigned __int64,1>::_Optional_destruct_base<unsigned __int64,1><unsigned __int64 & __ptr64>(struct std::in_place_t,unsigned __int64 & __ptr64) __ptr64:
Hash: 0x0000000000000000
Counters: 1
Function count: 1023
This is quite unfortunate as we are not interested in the code coverage of the standard library.
Our current cov.list file looks like this:
[clang]
source:*/VS2022/*=forbid
default=allow
I’ve tried to exclude using function
, though it expects a managed name. My understanding is that I can use *@std@@*
to filter based on the namespace, though it also excludes part of our code that has any function taking an argument defined in the standard library. As such, this ain’t a viable option.
I’ve already looked into the code (llvm-project/clang/lib/CodeGen/CodeGenModule.cpp at 7a28a5b3fee6c78ad59af79a3d03c00db153c49f · llvm/llvm-project · GitHub), though it ain’t obvious what ->getName()
returns. For functions, I believe this is only the mangled name, and for sources I believe this is the absolute path, based on my experimentation.
Do you know any way that that allows reducing the .profraw size that excludes the standard library?