[llvm] Implement MCDCTVIdxBuilder (LLVM side) (PR #80676)
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 11 18:57:54 PST 2024
================
@@ -223,9 +223,127 @@ Expected<int64_t> CounterMappingContext::evaluate(const Counter &C) const {
return LastPoppedValue;
}
+MCDCTVIdxBuilder::MCDCTVIdxBuilder(
+ std::function<NodeIDs(bool TellSize)> Fetcher) {
+ // Build Nodes and set up each InCount
+ int MaxID = -1;
+ Nodes.resize(std::get<0>(Fetcher(true)));
+ while (true) {
+ auto [ID1, FalseID1, TrueID1] = Fetcher(false);
+ if (ID1 == 0)
+ break;
+ int ID = ID1 - 1;
+ MaxID = std::max(MaxID, ID);
+ auto &Node = Nodes[ID];
+ Node.Conds[0].ID = FalseID1 - 1;
+ Node.Conds[1].ID = TrueID1 - 1;
+ for (unsigned I = 0; I < 2; ++I) {
+#ifndef NDEBUG
+ Node.Conds[I].Idx = INT_MIN;
+#endif
+ int NextID = Node.Conds[I].ID;
+ if (NextID >= 0)
+ ++Nodes[NextID].InCount;
+ }
+ }
+
+ if (MaxID < 0)
+ return;
+
+ // Sort key ordered by <-Width, Ord>
+ SmallVector<std::tuple<int, /// -Width
----------------
chapuni wrote:
I am using it as the sort key of comparator.
https://github.com/llvm/llvm-project/pull/80676
More information about the llvm-commits
mailing list