[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni edited https://github.com/llvm/llvm-project/pull/112702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni closed https://github.com/llvm/llvm-project/pull/112702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 01/12] [Coverage] Introduce `getBranchCounterPair()`. NFC. Thi

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread Jessica Paquette via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { ornata wrote: Ok, annotating the members sounds fine to me. https://github.com/llvm/llvm-project/pull/112702 __

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { +Counter Executed; +Counter Skipped; + }; + + BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { ---

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 01/11] [Coverage] Introduce `getBranchCounterPair()`. NFC. Thi

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-08 Thread NAKAMURA Takumi via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { chapuni wrote: `BranchCounterPair` is a local type and only `getBranchCounterPair()` emits it for now. I think it'd be

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { +Counter Executed; +Counter Skipped; + }; + + BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { +Co

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSing

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread Jessica Paquette via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { chapuni wrote: I wrote similar comments (from codegen side) in #112724 and I wanted to leave this side self-descriptive

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { +Counter Executed; chapuni wrote: I still wonder which pair of names would fit best. I adopted "Exec" from `BinOp`

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread Jessica Paquette via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread Jessica Paquette via cfe-commits
@@ -939,8 +939,17 @@ struct CounterCoverageMappingBuilder Counter Skipped; }; - BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { + BranchCounterPair + getBranchCounterPair(const Stmt *S, Counter ParentCnt, + std::optiona

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-07 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 1/9] [Coverage] Introduce `getBranchCounterPair()`. NFC. This

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSing

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { +Counter Executed; +Counter Skipped; + }; + + BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { +Co

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { +Counter Executed; +Counter Skipped; + }; + + BranchCounterPair getBranchCounterPair(const Stmt *S, Counter ParentCnt) { ---

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { ornata wrote: IIUC the point of this pair is given: ``` if (x) { // ... do something } else if (y) { // ... somethin

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { +Counter Executed; ornata wrote: Comments on member variables? E.g. ``` /// Counter tracking number of times the b

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-06 Thread Jessica Paquette via cfe-commits
@@ -938,6 +938,37 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + struct BranchCounterPair { ornata wrote: A doxygen comment here might be useful. https://github.com/llvm/llvm-project/pull/112702

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2025-01-05 Thread NAKAMURA Takumi via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, chapuni wrote: Done but I am still dubious namings would be appropriate. Not all users expect `[Exec

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-23 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 1/5] [Coverage] Introduce `getBranchCounterPair()`. NFC. This

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-21 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 1/4] [Coverage] Introduce `getBranchCounterPair()`. NFC. This

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-19 Thread NAKAMURA Takumi via cfe-commits
@@ -2221,27 +2249,27 @@ struct CounterCoverageMappingBuilder extendRegion(E->getRHS()); propagateCounts(getRegionCounter(E), E->getRHS()); +if (llvm::EnableSingleByteCoverage) chapuni wrote: This is a small refactor for below and this itself will

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-19 Thread NAKAMURA Takumi via cfe-commits
@@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSing

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-19 Thread NAKAMURA Takumi via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-18 Thread Jessica Paquette via cfe-commits
@@ -2221,27 +2249,27 @@ struct CounterCoverageMappingBuilder extendRegion(E->getRHS()); propagateCounts(getRegionCounter(E), E->getRHS()); +if (llvm::EnableSingleByteCoverage) ornata wrote: I think that in the future, it would be really useful to

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-18 Thread Jessica Paquette via cfe-commits
@@ -1804,9 +1832,10 @@ struct CounterCoverageMappingBuilder Counter LoopCount = addCounters(ParentCount, BackedgeCount, BC.ContinueCount); -Counter OutCount = -addCounters(BC.BreakCount, subtractCounters(LoopCount, BodyCount)); -if (OutCount != Pare

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-18 Thread Jessica Paquette via cfe-commits
@@ -1709,6 +1730,13 @@ struct CounterCoverageMappingBuilder : addCounters( addCounters(ParentCount, BackedgeCount, BodyBC.ContinueCount), IncrementBC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingle

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-18 Thread Jessica Paquette via cfe-commits
@@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSing

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-18 Thread Jessica Paquette via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-12-18 Thread Jessica Paquette via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, ornata wrote: I think changing the name is sufficient for making me less confused https://github.com

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-27 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 1/3] [Coverage] Introduce `getBranchCounterPair()`. NFC. This

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-24 Thread NAKAMURA Takumi via cfe-commits
chapuni wrote: @ornata I put #113115 as the final form. HTH https://github.com/llvm/llvm-project/pull/112702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -1709,6 +1730,13 @@ struct CounterCoverageMappingBuilder : addCounters( addCounters(ParentCount, BackedgeCount, BodyBC.ContinueCount), IncrementBC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingle

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -1645,22 +1662,26 @@ struct CounterCoverageMappingBuilder Counter CondCount = llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(BackedgeCount, BC.ContinueCount); +auto [ExecCount, Exi

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -1804,9 +1832,10 @@ struct CounterCoverageMappingBuilder Counter LoopCount = addCounters(ParentCount, BackedgeCount, BC.ContinueCount); -Counter OutCount = -addCounters(BC.BreakCount, subtractCounters(LoopCount, BodyCount)); -if (OutCount != Pare

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -1709,6 +1730,13 @@ struct CounterCoverageMappingBuilder : addCounters( addCounters(ParentCount, BackedgeCount, BodyBC.ContinueCount), IncrementBC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSingle

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -1592,6 +1605,13 @@ struct CounterCoverageMappingBuilder llvm::EnableSingleByteCoverage ? getRegionCounter(S->getCond()) : addCounters(ParentCount, BackedgeCount, BC.ContinueCount); +auto [ExecCount, ExitCount] = +(llvm::EnableSing

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, + Counter ParentCnt) { +Counter ExecCnt = getRegionCounter(S); +

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-18 Thread Jessica Paquette via cfe-commits
@@ -941,6 +941,19 @@ struct CounterCoverageMappingBuilder return Counter::getCounter(CounterMap[S]); } + std::pair getBranchCounterPair(const Stmt *S, ornata wrote: it's not immediately obvious what the pair represents from this function name. `getExe

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-17 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/112702 >From fc697f04fd6c9f3c217ce04e3f1dd082c1f1a705 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 16 Oct 2024 23:16:53 +0900 Subject: [PATCH 1/2] [Coverage] Introduce `getBranchCounterPair()`. NFC. This

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-17 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: NAKAMURA Takumi (chapuni) Changes This aggregates the generation of branch counter pair as `ExecCnt` and `SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment: - This change preserves the behavi

[clang] [Coverage] Introduce `getBranchCounterPair()`. NFC. (PR #112702)

2024-10-17 Thread NAKAMURA Takumi via cfe-commits
https://github.com/chapuni created https://github.com/llvm/llvm-project/pull/112702 This aggregates the generation of branch counter pair as `ExecCnt` and `SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment: - This change preserves the behavior of `llvm::EnableSingleByteCoverage`.