This is an archive of the discontinued LLVM Phabricator instance.

[InstrProf][WIP] Implement boolean counters in coverage
AbandonedPublic

Authored by gulfem on Jun 3 2022, 6:02 PM.

Details

Reviewers
None
Summary

This patch inserts 1-byte boolean 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 reuses that idea for coverage.
https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

This is a WIP prototype implementation which only implements boolean
counters for only a handful of control-flow statements (while, for, if, switch).
I will continue to extend it for other control-flow statements.

The current 8-byte counters mechanism add counters to minimal regions,
and infer the counters in the remaining regions via adding or
subtracting counters. Whenever there is control-flow merge, it adds
the counters from all the incoming regions. When we use boolean counters,
we can use a new counter expression called or instead of an and for such
cases. Therefore, this patch adds an Or kind into CounterExpression.

Similarly, 8-byte counters mechanism infers the counters in some regions
by 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. However, we are not going to be able to infer counters
by subtracting two execution counts when using boolean counters.
Therefore, we need to insert additional counters for the cases where we
need to subtract counters.

Diff Detail

Event Timeline

gulfem created this revision.Jun 3 2022, 6:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2022, 6:02 PM
gulfem requested review of this revision.Jun 3 2022, 6:02 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 3 2022, 6:02 PM
gulfem abandoned this revision.Jun 5 2023, 5:52 PM

Created a duplicate review by mistake.