[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)

2024-02-23 Thread Alan Phipps via llvm-branch-commits

https://github.com/evodius96 approved this pull request.

I think this needs to be on 18.x

https://github.com/llvm/llvm-project/pull/82571
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: [clang][CodeGen] Keep processing the rest of AST after encountering unsupported MC/DC expressions (#82464) (PR #82866)

2024-02-24 Thread Alan Phipps via llvm-branch-commits

https://github.com/evodius96 approved this pull request.

This should also be on 18.x

https://github.com/llvm/llvm-project/pull/82866
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] b89942c - [Coverage] Fix branch coverage merging in FunctionCoverageSummary::get() for instantiation

2021-05-11 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2021-05-11T13:04:59-05:00
New Revision: b89942c336a4506dabd5e1b2a6f1b5cbaddebe55

URL: 
https://github.com/llvm/llvm-project/commit/b89942c336a4506dabd5e1b2a6f1b5cbaddebe55
DIFF: 
https://github.com/llvm/llvm-project/commit/b89942c336a4506dabd5e1b2a6f1b5cbaddebe55.diff

LOG: [Coverage] Fix branch coverage merging in FunctionCoverageSummary::get() 
for instantiation

Fix branch coverage merging in FunctionCoverageSummary::get() for instantiation
groups.

This change corrects the implementation for the branch coverage summary to do
the same thing for branches that is done for lines and regions.  That is,
across function instantiations in an instantiation group, the maximum branch
coverage found in any of those instantiations is returned, with the total
number of branches being the same across instantiations.

Differential Revision: https://reviews.llvm.org/D102193

(cherry picked from commit eccb925147d5f262a3e74cc050d0665dd4e6d8db)

Added: 


Modified: 
llvm/test/tools/llvm-cov/branch-templates.cpp
llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
llvm/tools/llvm-cov/CoverageSummaryInfo.h

Removed: 




diff  --git a/llvm/test/tools/llvm-cov/branch-templates.cpp 
b/llvm/test/tools/llvm-cov/branch-templates.cpp
index 750dc7bd58f27..4797428f8835a 100644
--- a/llvm/test/tools/llvm-cov/branch-templates.cpp
+++ b/llvm/test/tools/llvm-cov/branch-templates.cpp
@@ -1,9 +1,9 @@
 // RUN: llvm-profdata merge %S/Inputs/branch-templates.proftext -o %t.profdata
 // RUN: llvm-cov show --show-expansions --show-branches=count 
%S/Inputs/branch-templates.o32l -instr-profile %t.profdata 
-path-equivalence=/tmp,%S %s | FileCheck %s
 // RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-templates.o32l 
-instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S %s | 
FileCheck %s -check-prefix=REPORT
+// RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-templates.o32l 
-instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s 
-check-prefix=REPORTFILE
 
 #include 
-
 template
 void unused(T x) {
   return;
@@ -45,3 +45,17 @@ int main() {
 // REPORT-NEXT: _Z4funcIfEiT_ 5   2  60.00% 7  
 3  57.14% 2   1  50.00%
 // REPORT-NEXT: ---
 // REPORT-NEXT: TOTAL22   7  68.18%31  
11  64.52%12   6  50.00%
+
+// Make sure the covered branch tally for the function instantiation group is
+// merged to reflect maximum branch coverage of a single instantiation, just
+// like what is done for lines and regions. Also, the total branch tally
+// summary for an instantiation group should agree with the total number of
+// branches in the definition (In this case, 2 and 6 for func<>() and main(),
+// respectively).  This is returned by: FunctionCoverageSummary::get(const
+// InstantiationGroup &Group, ...)
+
+// REPORTFILE: Filename  RegionsMissed Regions 
Cover   Functions  Missed Functions  Executed   Lines  Missed Lines 
CoverBranches   Missed Branches Cover
+// REPORTFILE-NEXT: ---
+// REPORTFILE-NEXT: branch-templates.cpp  12 3
75.00%   2 0   100.00%  17 4
76.47%   8 450.00%
+// REPORTFILE-NEXT: ---
+// REPORTFILE-NEXT: TOTAL  12 3
75.00%   2 0   100.00%  17 4
76.47%   8 450.00%

diff  --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp 
b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
index 4a0a86168908f..10e059adeb7d8 100644
--- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
+++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
@@ -100,11 +100,7 @@ FunctionCoverageSummary::get(const InstantiationGroup 
&Group,
   for (const auto &FCS : Summaries.drop_front()) {
 Summary.RegionCoverage.merge(FCS.RegionCoverage);
 Summary.LineCoverage.merge(FCS.LineCoverage);
-
-// Sum branch coverage across instantiation groups for the summary rather
-// than "merge" the maximum count. This is a clearer view into whether all
-// created branches are covered.
-Summary.BranchCoverage += FCS.BranchCoverage;
+Summary.BranchCoverage.merge(FCS.BranchCoverage);
   }
   return Summary;
 }

diff  --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.h 
b/llvm/tools/llvm-cov/CoverageSummaryInfo.h
index 4bc1c24a079f2..62e7cad1012b1 100644
--- a/llvm/tools/llvm-cov/CoverageSummaryInfo.h
+++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.h
@@ -123,6 +123,11 @@ class BranchCoverageInfo {
 return *this;
   }
 
+  void merge(const BranchCoverageInfo &RHS) {
+Covered = std::max(Covered, RHS.Covered);
+NumBranches = std::max(NumBranches, RHS.NumBranches);
+  }
+
   size_t getCovered() const { return Covered; }
 
   

[llvm-branch-commits] [clang] 16f3401 - [Coverage] Fix test failures from commit rG9f2967bcfe2f

2021-01-05 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2021-01-05T13:35:52-06:00
New Revision: 16f3401eae4310c95163269c41d9b45261f0c7c3

URL: 
https://github.com/llvm/llvm-project/commit/16f3401eae4310c95163269c41d9b45261f0c7c3
DIFF: 
https://github.com/llvm/llvm-project/commit/16f3401eae4310c95163269c41d9b45261f0c7c3.diff

LOG: [Coverage] Fix test failures from commit rG9f2967bcfe2f

Fix test failures with Branch Coverage tests from commit rG9f2967bcfe2f
that failed build on builder clang-x64-windows-msvc while building llvm:
http://lab.llvm.org:8011/#builders/123/builds/2155

Added: 


Modified: 
clang/test/CoverageMapping/branch-constfolded.cpp
clang/test/CoverageMapping/branch-macros.cpp
clang/test/CoverageMapping/branch-mincounters.cpp
clang/test/CoverageMapping/branch-templates.cpp
clang/test/Profile/branch-logical-mixed.cpp
clang/test/Profile/branch-profdup.cpp

Removed: 




diff  --git a/clang/test/CoverageMapping/branch-constfolded.cpp 
b/clang/test/CoverageMapping/branch-constfolded.cpp
index bb7c675e3ef7..5173286addbb 100644
--- a/clang/test/CoverageMapping/branch-constfolded.cpp
+++ b/clang/test/CoverageMapping/branch-constfolded.cpp
@@ -1,6 +1,6 @@
 // Test that branch regions are not generated for constant-folded conditions.
 
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name branch-constfolded.cpp 
%s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -main-file-name branch-constfolded.cpp %s | FileCheck %s
 
 // CHECK-LABEL: _Z6fand_0b:
 bool fand_0(bool a) {

diff  --git a/clang/test/CoverageMapping/branch-macros.cpp 
b/clang/test/CoverageMapping/branch-macros.cpp
index d5bc47fbef76..0f9ae791a355 100644
--- a/clang/test/CoverageMapping/branch-macros.cpp
+++ b/clang/test/CoverageMapping/branch-macros.cpp
@@ -1,7 +1,7 @@
 // Test that branch regions are generated for conditions in nested macro
 // expansions.
 
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name branch-macros.cpp %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -main-file-name branch-macros.cpp %s | FileCheck %s
 
 #define COND1 (a == b)
 #define COND2 (a != b)

diff  --git a/clang/test/CoverageMapping/branch-mincounters.cpp 
b/clang/test/CoverageMapping/branch-mincounters.cpp
index 68e691684970..6d4341cbeafd 100644
--- a/clang/test/CoverageMapping/branch-mincounters.cpp
+++ b/clang/test/CoverageMapping/branch-mincounters.cpp
@@ -1,7 +1,7 @@
 // Test to ensure right number of counters are allocated and used for nested
 // logical operators on branch conditions for branch coverage.
 
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name branch-logical-mixed.cpp 
%s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -main-file-name branch-logical-mixed.cpp %s | FileCheck %s
 
 
 // CHECK-LABEL: _Z5func1ii:

diff  --git a/clang/test/CoverageMapping/branch-templates.cpp 
b/clang/test/CoverageMapping/branch-templates.cpp
index 9e312df9b2de..1fd01218c903 100644
--- a/clang/test/CoverageMapping/branch-templates.cpp
+++ b/clang/test/CoverageMapping/branch-templates.cpp
@@ -1,7 +1,7 @@
 // Test that branch regions are generated for conditions in function template
 // instantiations.
 
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name branch-templates.cpp %s 
| FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 
-fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping 
-emit-llvm-only -main-file-name branch-templates.cpp %s | FileCheck %s
 
 template
 void unused(T x) {

diff  --git a/clang/test/Profile/branch-logical-mixed.cpp 
b/clang/test/Profile/branch-logical-mixed.cpp
index e6f546d3ac4b..cbfcf061f152 100644
--- a/clang/test/Profile/branch-logical-mixed.cpp
+++ b/clang/test/Profile/branch-logical-mixed.cpp
@@ -1,7 +1,7 @@
 // Test to ensure instrumentation of logical operator RHS True/False counters
 // are being instrumented for branch coverage
 
-// RUN: %clang_cc1 -main-file-name branch-logical-mixed.cpp %s -o - -emit-llvm 
-fprofile-instrument=clang | FileCheck -allow-deprecated-dag-overlap %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -main-file-name 
branch-logical-mixed.cpp %s -o - -emit-llvm -fprofile-instrument=clang | 
FileCheck -allow-deprecated-dag-overlap %s
 
 
 // CHECK: @[[FUNC:__profc__Z4funcv]] = private global [61 x i64] 
zeroinitializer

diff  --git a/clang/test/Profil

[llvm-branch-commits] [clang] 2168942 - [Coverage] Fix Profile test failures from commit rG9f2967bcfe2f

2021-01-05 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2021-01-05T14:53:07-06:00
New Revision: 216894211713bbb1e8beb249f2b008c11a9d8c2c

URL: 
https://github.com/llvm/llvm-project/commit/216894211713bbb1e8beb249f2b008c11a9d8c2c
DIFF: 
https://github.com/llvm/llvm-project/commit/216894211713bbb1e8beb249f2b008c11a9d8c2c.diff

LOG: [Coverage] Fix Profile test failures from commit rG9f2967bcfe2f

Fix test failures with Branch Coverage tests from commit rG9f2967bcfe2f
that failed build on builder clang-x64-windows-msvc while building llvm:
http://lab.llvm.org:8011/#/builders/123/builds/2162

Added: 


Modified: 
clang/test/Profile/branch-logical-mixed.cpp

Removed: 




diff  --git a/clang/test/Profile/branch-logical-mixed.cpp 
b/clang/test/Profile/branch-logical-mixed.cpp
index cbfcf061f152..04b51d81d13b 100644
--- a/clang/test/Profile/branch-logical-mixed.cpp
+++ b/clang/test/Profile/branch-logical-mixed.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -main-file-name 
branch-logical-mixed.cpp %s -o - -emit-llvm -fprofile-instrument=clang | 
FileCheck -allow-deprecated-dag-overlap %s
 
 
-// CHECK: @[[FUNC:__profc__Z4funcv]] = private global [61 x i64] 
zeroinitializer
+// CHECK: @[[FUNC:__profc__Z4funcv]] = {{.*}} global [61 x i64] zeroinitializer
 
 
 // CHECK-LABEL: @_Z4funcv()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] ebcc8dc - [Coverage] Refactor three tests from commit rG9f2967bcfe2f

2021-01-07 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2021-01-07T11:18:31-06:00
New Revision: ebcc8dcb68aa37f34a87641b0c8b73086712a3cf

URL: 
https://github.com/llvm/llvm-project/commit/ebcc8dcb68aa37f34a87641b0c8b73086712a3cf
DIFF: 
https://github.com/llvm/llvm-project/commit/ebcc8dcb68aa37f34a87641b0c8b73086712a3cf.diff

LOG: [Coverage] Refactor three tests from commit rG9f2967bcfe2f

Refactor three tests to not depend on other test files as input but to instead
refer to "Inputs" subdirectory.

Added: 
llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
llvm/test/tools/llvm-cov/branch-c-general.test

Modified: 
llvm/test/tools/llvm-cov/branch-export-json.test
llvm/test/tools/llvm-cov/branch-export-lcov.test
llvm/test/tools/llvm-cov/branch-noShowBranch.test

Removed: 
llvm/test/tools/llvm-cov/branch-c-general.c



diff  --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c 
b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
new file mode 100644
index ..2e7e773e5c39
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
@@ -0,0 +1,260 @@
+// Test visualization of general branch constructs in C.
+
+
+
+
+
+void simple_loops() {
+  int i;
+  for (i = 0; i < 100; ++i) {
+  }
+  while (i > 0)
+i--;
+  do {} while (i++ < 75);
+
+}
+
+void conditionals() {
+  for (int i = 0; i < 100; ++i) {
+if (i % 2) {
+  if (i) {}
+} else if (i % 3) {
+  if (i) {}
+} else {
+  if (i) {}
+}
+
+if (1 && i) {}
+if (0 || i) {}
+  }
+
+}
+
+void early_exits() {
+  int i = 0;
+
+  if (i) {}
+
+  while (i < 100) {
+i++;
+if (i > 50)
+  break;
+if (i % 2)
+  continue;
+  }
+
+  if (i) {}
+
+  do {
+if (i > 75)
+  return;
+else
+  i++;
+  } while (i < 100);
+
+  if (i) {}
+
+}
+
+void jumps() {
+  int i;
+
+  for (i = 0; i < 2; ++i) {
+goto outofloop;
+// Never reached -> no weights
+if (i) {}
+  }
+
+outofloop:
+  if (i) {}
+
+  goto loop1;
+
+  while (i) {
+  loop1:
+if (i) {}
+  }
+
+  goto loop2;
+first:
+second:
+third:
+  i++;
+  if (i < 3)
+goto loop2;
+
+  while (i < 3) {
+  loop2:
+switch (i) {
+case 0:
+  goto first;
+case 1:
+  goto second;
+case 2:
+  goto third;
+}
+  }
+
+  for (i = 0; i < 10; ++i) {
+goto withinloop;
+// never reached -> no weights
+if (i) {}
+  withinloop:
+if (i) {}
+  }
+
+}
+
+void switches() {
+  static int weights[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5};
+
+  // No cases -> no weights
+  switch (weights[0]) {
+  default:
+break;
+  }
+
+  for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {
+switch (i[weights]) {
+case 1:
+  if (i) {}
+  // fallthrough
+case 2:
+  if (i) {}
+  break;
+case 3:
+  if (i) {}
+  continue;
+case 4:
+  if (i) {}
+  switch (i) {
+  case 6 ... 9:
+if (i) {}
+continue;
+  }
+
+default:
+  if (i == len - 1)
+return;
+}
+  }
+
+  // Never reached -> no weights
+  if (weights[0]) {}
+
+}
+
+void big_switch() {
+  for (int i = 0; i < 32; ++i) {
+switch (1 << i) {
+case (1 << 0):
+  if (i) {}
+  // fallthrough
+case (1 << 1):
+  if (i) {}
+  break;
+case (1 << 2) ... (1 << 12):
+  if (i) {}
+  break;
+  // The branch for the large case range above appears after the case body.
+
+case (1 << 13):
+  if (i) {}
+  break;
+case (1 << 14) ... (1 << 28):
+  if (i) {}
+  break;
+// The branch for the large case range above appears after the case body.
+
+case (1 << 29) ... ((1 << 29) + 1):
+  if (i) {}
+  break;
+default:
+  if (i) {}
+  break;
+}
+  }
+
+}
+
+void boolean_operators() {
+  int v;
+  for (int i = 0; i < 100; ++i) {
+v = i % 3 || i;
+
+v = i % 3 && i;
+
+v = i % 3 || i % 2 || i;
+
+v = i % 2 && i % 3 && i;
+  }
+
+}
+
+void boolop_loops() {
+  int i = 100;
+
+  while (i && i > 50)
+i--;
+
+  while ((i % 2) || (i > 0))
+i--;
+
+  for (i = 100; i && i > 50; --i);
+
+  for (; (i % 2) || (i > 0); --i);
+
+}
+
+void conditional_operator() {
+  int i = 100;
+
+  int j = i < 50 ? i : 1;
+
+  int k = i ?: 0;
+
+}
+
+void do_fallthrough() {
+  for (int i = 0; i < 10; ++i) {
+int j = 0;
+do {
+  // The number of exits out of this do-loop via the break statement
+  // exceeds the counter value for the loop (which does not include the
+  // fallthrough count). Make sure that does not violate any assertions.
+  if (i < 8) break;
+  j++;
+} while (j < 2);
+  }
+}
+
+static void static_func() {
+  for (int i = 0; i < 10; ++i) {
+  }
+}
+
+
+
+
+
+
+
+
+
+
+int main(int argc, const char *argv[]) {
+  simple_loops();
+  conditionals();
+  early_exits();
+  jumps();
+  switches();
+  big_switch();
+  boolean_operators();
+  boolop_loops();
+  conditional_

[llvm-branch-commits] [clang] b920adf - This is a test commit

2020-12-23 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2020-12-23T12:57:27-06:00
New Revision: b920adf3b4f16bef8dde937b67874d8e8ac1030e

URL: 
https://github.com/llvm/llvm-project/commit/b920adf3b4f16bef8dde937b67874d8e8ac1030e
DIFF: 
https://github.com/llvm/llvm-project/commit/b920adf3b4f16bef8dde937b67874d8e8ac1030e.diff

LOG: This is a test commit

Added: 


Modified: 
clang/lib/CodeGen/README.txt

Removed: 




diff  --git a/clang/lib/CodeGen/README.txt b/clang/lib/CodeGen/README.txt
index e6d61095bf23..e4fd7816d65c 100644
--- a/clang/lib/CodeGen/README.txt
+++ b/clang/lib/CodeGen/README.txt
@@ -16,6 +16,7 @@ extension. For example, if the bitfield width is 8 and it is
 appropriately aligned then is is a lot shorter to just load the char
 directly.
 
+
 //===-===//
 
 It may be worth avoiding creation of alloca's for formal arguments



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] bbd758a - Revert "This is a test commit"

2020-12-23 Thread Alan Phipps via llvm-branch-commits

Author: Alan Phipps
Date: 2020-12-23T13:04:37-06:00
New Revision: bbd758a7913b1c374ca26e5a734a01200754fe0e

URL: 
https://github.com/llvm/llvm-project/commit/bbd758a7913b1c374ca26e5a734a01200754fe0e
DIFF: 
https://github.com/llvm/llvm-project/commit/bbd758a7913b1c374ca26e5a734a01200754fe0e.diff

LOG: Revert "This is a test commit"

This reverts commit b920adf3b4f16bef8dde937b67874d8e8ac1030e.

Added: 


Modified: 
clang/lib/CodeGen/README.txt

Removed: 




diff  --git a/clang/lib/CodeGen/README.txt b/clang/lib/CodeGen/README.txt
index e4fd7816d65c..e6d61095bf23 100644
--- a/clang/lib/CodeGen/README.txt
+++ b/clang/lib/CodeGen/README.txt
@@ -16,7 +16,6 @@ extension. For example, if the bitfield width is 8 and it is
 appropriately aligned then is is a lot shorter to just load the char
 directly.
 
-
 //===-===//
 
 It may be worth avoiding creation of alloca's for formal arguments



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [Coverage] Sort `MCDCRecord::ExecVectors` order by Bitmap index (PR #121195)

2024-12-28 Thread Alan Phipps via llvm-branch-commits

evodius96 wrote:

Hi! Due to the holidays, it will be another week before I can look at these 
reviews, but I really would like to look at them to keep up on what you're 
doing. Are you in a hurry to get them in prior to branching?

https://github.com/llvm/llvm-project/pull/121195
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [MC/DC] Introduce `-fmcdc-single-conditions` to include also single conditions (PR #125484)

2025-02-03 Thread Alan Phipps via llvm-branch-commits

evodius96 wrote:

This is pertinent to #109930 from Validas as well, and they would like 
something like this to be included by default to make it less confusing for 
users of MC/DC.  On the other hand, as I point out in the issue, I think 
introducing MC/DC for single-conditions is redundant (given branch coverage) 
and introduces unnecessary overhead. So, that's an argument for keeping it as a 
separate option and perhaps finding another way to work branch coverage into 
the overall MC/DC metric.

Also, Branch Coverage gives you counts for switch statement cases, whereas I'm 
not sure that makes sense for single-condition MC/DC, though perhaps that's 
overkill.

https://github.com/llvm/llvm-project/pull/125484
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [MC/DC] Enable nested expressions (PR #125413)

2025-02-28 Thread Alan Phipps via llvm-branch-commits


@@ -275,49 +276,57 @@ struct MapRegionCounters : public 
RecursiveASTVisitor {
   // an AST Stmt node.  MC/DC will use it to to signal when the top of a
   // logical operation (boolean expression) nest is encountered.
   bool dataTraverseStmtPost(Stmt *S) {
-/// If MC/DC is not enabled, MCDCMaxCond will be set to 0. Do nothing.
-if (MCDCMaxCond == 0)
+if (DecisionStack.empty())
   return true;
 
-if (const Expr *E = dyn_cast(S)) {
-  const BinaryOperator *BinOp = 
dyn_cast(E->IgnoreParens());
-  if (BinOp && BinOp->isLogicalOp()) {
-assert(LogOpStack.back() == BinOp);
-LogOpStack.pop_back();
-
-/// At the top of logical operator nest:
-if (LogOpStack.empty()) {
-  /// Was the "split-nested" logical operator case encountered?
-  if (SplitNestedLogicalOp) {
-unsigned DiagID = Diag.getCustomDiagID(
-DiagnosticsEngine::Warning,
-"unsupported MC/DC boolean expression; "
-"contains an operation with a nested boolean expression. "
-"Expression will not be covered");
-Diag.Report(S->getBeginLoc(), DiagID);
-return true;
-  }
-
-  /// Was the maximum number of conditions encountered?
-  if (NumCond > MCDCMaxCond) {
-unsigned DiagID = Diag.getCustomDiagID(
-DiagnosticsEngine::Warning,
-"unsupported MC/DC boolean expression; "
-"number of conditions (%0) exceeds max (%1). "
-"Expression will not be covered");
-Diag.Report(S->getBeginLoc(), DiagID) << NumCond << MCDCMaxCond;
-return true;
-  }
-
-  // Otherwise, allocate the Decision.
-  MCDCState.DecisionByStmt[BinOp].ID = MCDCState.DecisionByStmt.size();
-}
-return true;
+/// If MC/DC is not enabled, MCDCMaxCond will be set to 0. Do nothing.
+assert(MCDCMaxCond > 0);
+
+auto &StackTop = DecisionStack.back();
+
+if (StackTop.DecisionExpr != S) {
+  if (StackTop.Leaves.contains(S)) {
+assert(StackTop.Split);
+StackTop.Split = false;
   }
+
+  return true;
+}
+
+/// Allocate the entry (with Valid=false)
+auto &DecisionEntry =
+MCDCState
+.DecisionByStmt[CodeGenFunction::stripCond(StackTop.DecisionExpr)];
+
+/// Was the "split-nested" logical operator case encountered?
+if (false && DecisionStack.size() > 1) {

evodius96 wrote:

If I understand correctly --- I don't think I see a purpose in warning about 
these now that the code effectively handles them.  I would deprecate or just 
remove it.

https://github.com/llvm/llvm-project/pull/125413
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits