aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2025-01-10 19:22:46 +0900
committerNAKAMURA Takumi <geek4civic@gmail.com>2025-01-10 19:22:46 +0900
commit8b02a27fc607ebc54c5a811188b3cea5063564e7 (patch)
treec1ca7d4acca553301204ebb83383aa87cb59311a /clang/lib/CodeGen/CodeGenModule.h
parent694a772457b2999b7bd68625a16bf0755e95dcdb (diff)
parent397ac44f623f891d8f05d6673a95984ac0a26671 (diff)
downloadllvm-users/chapuni/cov/merge/mcdcsort.zip
llvm-users/chapuni/cov/merge/mcdcsort.tar.gz
llvm-users/chapuni/cov/merge/mcdcsort.tar.bz2
Merge branch 'main' into users/chapuni/cov/merge/mcdcsortusers/chapuni/cov/merge/mcdcsort
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 741b0f1..d5ef1a7 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -102,6 +102,50 @@ enum ForDefinition_t : bool {
ForDefinition = true
};
+/// The Counter with an optional additional Counter for
+/// branches. `Skipped` counter can be calculated with `Executed` and
+/// a common Counter (like `Parent`) as `(Parent-Executed)`.
+///
+/// In SingleByte mode, Counters are binary. Subtraction is not
+/// applicable (but addition is capable). In this case, both
+/// `Executed` and `Skipped` counters are required. `Skipped` is
+/// `None` by default. It is allocated in the coverage mapping.
+///
+/// There might be cases that `Parent` could be induced with
+/// `(Executed+Skipped)`. This is not always applicable.
+class CounterPair {
+public:
+ /// Optional value.
+ class ValueOpt {
+ private:
+ static constexpr uint32_t None = (1u << 31); /// None is allocated.
+ static constexpr uint32_t Mask = None - 1;
+
+ uint32_t Val;
+
+ public:
+ ValueOpt() : Val(None) {}
+
+ ValueOpt(unsigned InitVal) {
+ assert(!(InitVal & ~Mask));
+ Val = InitVal;
+ }
+
+ bool hasValue() const { return !(Val & None); }
+
+ operator uint32_t() const { return Val; }
+ };
+
+ ValueOpt Executed;
+ ValueOpt Skipped; /// May be None.
+
+ /// Initialized with Skipped=None.
+ CounterPair(unsigned Val) : Executed(Val) {}
+
+ // FIXME: Should work with {None, None}
+ CounterPair() : Executed(0) {}
+};
+
struct OrderGlobalInitsOrStermFinalizers {
unsigned int priority;
unsigned int lex_order;