diff options
author | gulfemsavrun <gulfem@google.com> | 2024-02-26 14:44:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 14:44:55 -0800 |
commit | 23f895f6567e0a4cef45cfc9d96d817a454b6e8f (patch) | |
tree | 3b0987a3668b550b1752865c4362ccc91bd9ec60 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 7789fb6604e5319ae46896285a264920015f8771 (diff) | |
download | llvm-23f895f6567e0a4cef45cfc9d96d817a454b6e8f.zip llvm-23f895f6567e0a4cef45cfc9d96d817a454b6e8f.tar.gz llvm-23f895f6567e0a4cef45cfc9d96d817a454b6e8f.tar.bz2 |
[InstrProf] Single byte counters in coverage (#75425)
This patch inserts 1-byte counters instead of an 8-byte counters into
llvm profiles for source-based code coverage. The origial idea was
proposed as block-cov for PGO, and this patch repurposes that idea for
coverage: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4
The current 8-byte counters mechanism add counters to minimal regions,
and infer the counters in the remaining regions via adding or
subtracting counters. For example, it infers the counter in the if.else
region by subtracting the counters between if.entry and if.then regions
in an if statement. Whenever there is a control-flow merge, it adds the
counters from all the incoming regions. However, we are not going to be
able to infer counters by subtracting two execution counts when using
single-byte counters. Therefore, this patch conservatively inserts
additional counters for the cases where we need to add or subtract
counters.
RFC:
https://discourse.llvm.org/t/rfc-single-byte-counters-for-source-based-code-coverage/75685
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 95e457b..1550b00 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -858,6 +858,7 @@ void CodeGenModule::Release() { checkAliases(); EmitDeferredUnusedCoverageMappings(); CodeGenPGO(*this).setValueProfilingFlag(getModule()); + CodeGenPGO(*this).setProfileVersion(getModule()); if (CoverageMapping) CoverageMapping->emit(); if (CodeGenOpts.SanitizeCfiCrossDso) { |