[llvm] Introduce mcdc::TVIdxBuilder (LLVM side, NFC) (PR #80676)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 02:50:23 PDT 2024


================
@@ -223,9 +223,130 @@ Expected<int64_t> CounterMappingContext::evaluate(const Counter &C) const {
   return LastPoppedValue;
 }
 
+mcdc::TVIdxBuilder::TVIdxBuilder(const SmallVectorImpl<ConditionIDs> &NextIDs,
+                                 int Offset)
+    : Indices(NextIDs.size()) {
+  // Construct Nodes and set up each InCount
+  auto N = NextIDs.size();
+  SmallVector<MCDCNode> Nodes(N);
+  for (unsigned ID = 0; ID < N; ++ID) {
+    for (unsigned C = 0; C < 2; ++C) {
+#ifndef NDEBUG
+      Indices[ID][C] = INT_MIN;
+#endif
+      auto NextID = NextIDs[ID][C];
+      Nodes[ID].NextIDs[C] = NextID;
+      if (NextID >= 0)
+        ++Nodes[NextID].InCount;
+    }
+  }
+
+  // Sort key ordered by <-Width, Ord>
----------------
chapuni wrote:

https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798#other-minor-implementations-5

I think it may be available for integrating branch and mcdc.

See also;
https://discourse.llvm.org/t/rfc-region-branch-coverage-by-bitmap/79629#branch-coverage-and-mcdc-test-vectors-4

https://github.com/llvm/llvm-project/pull/80676


More information about the llvm-commits mailing list