Clang has a few options related to coverage-style profiling. The command line reference doesn't really say what any of them do:
--coverage
-fprofile-arcs
-fprofile-instr-generate
-ftest-coverage
-fcoverage-mapping
According to the llvm-cov docs --coverage
enables -fprofile-arcs
and -ftest-coverage
and maybe more.
Both -fprofile-..
flags add instrumentation in some way to record execution counts, but do they do exactly the same thing? If so why have both?
The llvm-cov docs say to use -fprofile-arcs
with llvm-cov gcov
but -fprofile-instr-generate
with llvm-cov show
. Why? What is going on here?
And what do -fcoverage-mapping
and -ftest-coverage
do exactly?
Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.
LLVM is a backend compiler meant to build compilers on top of it. It deals with optimizations and production of code adapted to the target architecture. CLang is a front end which parses C, C++ and Objective C code and translates it into a representation suitable for LLVM.
Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection (GCC), supporting most of its compilation flags and unofficial language extensions.
The Clang tool is a front end compiler that is used to compile programming languages such as C++, C, Objective C++ and Objective C into machine code. Clang is also used as a compiler for frameworks like OpenMP, OpenCL, RenderScript, CUDA and HIP.
I started reading the code, and as far as I can tell:
--coverage
enables -ftest-coverage
, -fprofile-arcs
, and also adds -u__llvm_runtime_variable
on Linux, or something like that.
-fprofile-arcs
and -fprofile-instr-generate
are different. The former adds -femit-coverage-data
and the latter adds -fprofile-instrument=clang
(other options are "none" or "llvm").
-ftest-coverage
adds -femit-coverage-notes
-fcoverage-mapping
adds -fcoverage-mapping
Then the options have the following effect:
-ftest-coverage
: "Don't run the GCov pass, for testing." (that is... confusing)-femit-coverage-data
: Create a GCDA file.-femit-coverage-notes
: Create a GCNO file.-fprofile-instrument=clang
: One of the following options:ProfileNone, // Profile instrumentation is turned off.
ProfileClangInstr, // Clang instrumentation to generate execution counts
// to use with PGO.
ProfileIRInstr, // IR level PGO instrumentation in LLVM.
So that answers some questions, but there does indeed seem to be two totally different profiling systems and I'm not sure of the difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With