[clang] Add option to avoid generating coverage mappings for unused functions (PR #92582)
Zequan Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu May 23 07:49:38 PDT 2024
ZequanWu wrote:
> The problem that this solves is related to binary size. In situations where a large C API is in generated code but a small part of the API is used, the size of __llvm_prf_names and __llvm_cov_fun sections can be prohibitively large. This flag offers a way to reduce binary size in this case assuming you aren't concerned with coverage of non-emitted code.
There's some ways to reduce the instrumented binary size on code coverage.
1. Single byte counter: https://discourse.llvm.org/t/rfc-single-byte-counters-for-source-based-code-coverage/75685. If you don't care about the exact number of execution of of covered regions and just want to know if those regions ever got executed, this is a good option for it. This makes each counter 1 byte instead of 8 bytes.
2. Binary profile correlation: https://discourse.llvm.org/t/rfc-add-binary-profile-correlation-to-not-load-profile-metadata-sections-into-memory-at-runtime/74565. With this mode, it still generates the same `__llvm_prf_names` and `__llvm_prf_data` sections, but they can be stripped away before binary starts running. At merging stage, you need to provide the unstripped version of the binary to restore the information in those stripped sections. Basically, this reduces the stripped instrumented-binary size and raw profiles size.
https://github.com/llvm/llvm-project/pull/92582
More information about the cfe-commits
mailing list