[llvm-branch-commits] [llvm] Bump version to 18.1.7 (PR #93723)
whentojump wrote: Hi @tstellar are we planning to have one more 18.x release? https://github.com/llvm/llvm-project/pull/93723 ___ 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] Bump version to 18.1.7 (PR #93723)
whentojump wrote: Thanks for the info. Will you please consider https://github.com/llvm/llvm-project/compare/release/18.x...chapuni:llvm-project:release/18.x, which fixes an assertion violation? If so, I can do a PR. cc @chapuni https://github.com/llvm/llvm-project/pull/93723 ___ 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] [Coverage] Handles macros from system headers and nested macros in scratch space (PR #94438)
https://github.com/whentojump created https://github.com/llvm/llvm-project/pull/94438 Backports #89869 and #91446 (and associated tests in 3591da9f1ccbd8b19fef4814f96638dbbe9c2b40) that fixes missing code regions and `llvm-cov` crashes. With them, we are able to measure MC/DC of large C/C++ projects like LLVM itself and Linux kernel. >From 6a7700a2ed095e3d4e153dcedbbe1f14e0565501 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Mon, 20 May 2024 18:06:03 +0900 Subject: [PATCH 1/3] [Coverage] Rework !SystemHeadersCoverage (#91446) - Introduce `LeafExprSet`, - Suppress traversing LAnd and LOr expr under system headers. - Handle LAnd and LOr as instrumented leaves to override `!isInstrumentedCondition(C)`. - Replace Loc with FileLoc if it is expanded with system headers. Fixes #78920 llvmorg-19-init-11775-g702a2b627ff4 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 48 +++--- .../CoverageMapping/mcdc-system-headers.cpp | 50 +++ 2 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 clang/test/CoverageMapping/mcdc-system-headers.cpp diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index ae4e6d4c88c02..c284df9d82269 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -17,6 +17,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ProfileData/Coverage/CoverageMapping.h" @@ -325,16 +326,26 @@ class CoverageMappingBuilder { llvm::SmallSet Visited; SmallVector, 8> FileLocs; -for (const auto &Region : SourceRegions) { +for (auto &Region : SourceRegions) { SourceLocation Loc = Region.getBeginLoc(); + + // Replace Loc with FileLoc if it is expanded with system headers. + if (!SystemHeadersCoverage && SM.isInSystemMacro(Loc)) { +auto BeginLoc = SM.getSpellingLoc(Loc); +auto EndLoc = SM.getSpellingLoc(Region.getEndLoc()); +if (SM.isWrittenInSameFile(BeginLoc, EndLoc)) { + Loc = SM.getFileLoc(Loc); + Region.setStartLoc(Loc); + Region.setEndLoc(SM.getFileLoc(Region.getEndLoc())); +} + } + FileID File = SM.getFileID(Loc); if (!Visited.insert(File).second) continue; - // Do not map FileID's associated with system headers unless collecting - // coverage from system headers is explicitly enabled. - if (!SystemHeadersCoverage && SM.isInSystemHeader(SM.getSpellingLoc(Loc))) -continue; + assert(SystemHeadersCoverage || + !SM.isInSystemHeader(SM.getSpellingLoc(Loc))); unsigned Depth = 0; for (SourceLocation Parent = getIncludeOrExpansionLoc(Loc); @@ -816,6 +827,10 @@ struct CounterCoverageMappingBuilder /// A stack of currently live regions. llvm::SmallVector RegionStack; + /// Set if the Expr should be handled as a leaf even if it is kind of binary + /// logical ops (&&, ||). + llvm::DenseSet LeafExprSet; + /// An object to manage MCDC regions. MCDCCoverageBuilder MCDCBuilder; @@ -1041,7 +1056,10 @@ struct CounterCoverageMappingBuilder // region onto RegionStack but immediately pop it (which adds it to the // function's SourceRegions) because it doesn't apply to any other source // code other than the Condition. -if (CodeGenFunction::isInstrumentedCondition(C)) { +// With !SystemHeadersCoverage, binary logical ops in system headers may be +// treated as instrumentable conditions. +if (CodeGenFunction::isInstrumentedCondition(C) || +LeafExprSet.count(CodeGenFunction::stripCond(C))) { MCDCConditionID ID = MCDCBuilder.getCondID(C); MCDCConditionID TrueID = IDPair.TrueID; MCDCConditionID FalseID = IDPair.FalseID; @@ -1977,7 +1995,20 @@ struct CounterCoverageMappingBuilder subtractCounters(ParentCount, TrueCount)); } + /// Check if E belongs to system headers. + bool isExprInSystemHeader(const BinaryOperator *E) const { +return (!SystemHeadersCoverage && +SM.isInSystemHeader(SM.getSpellingLoc(E->getOperatorLoc())) && +SM.isInSystemHeader(SM.getSpellingLoc(E->getBeginLoc())) && +SM.isInSystemHeader(SM.getSpellingLoc(E->getEndLoc(; + } + void VisitBinLAnd(const BinaryOperator *E) { +if (isExprInSystemHeader(E)) { + LeafExprSet.insert(E); + return; +} + bool IsRootNode = MCDCBuilder.isIdle(); // Keep track of Binary Operator and assign MCDC condition IDs. @@ -2031,6 +2062,11 @@ struct CounterCoverageMappingBuilder } void VisitBinLOr(const BinaryOperator *E) { +if (isExprInSystemHeader(E)) { + LeafExprSet.insert(E); + return; +} + bool IsRootNode = MCDCBuilder.isIdle(); // Keep track of B
[llvm-branch-commits] [clang] [Coverage] Handles macros from system headers and nested macros in scratch space (PR #94438)
https://github.com/whentojump milestoned https://github.com/llvm/llvm-project/pull/94438 ___ 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] [Coverage] Handles macros from system headers and nested macros in scratch space (PR #94438)
https://github.com/whentojump edited https://github.com/llvm/llvm-project/pull/94438 ___ 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] [Coverage] Handles macros from system headers and nested macros in scratch space (PR #94438)
https://github.com/whentojump closed https://github.com/llvm/llvm-project/pull/94438 ___ 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] Backport 0bf4f82 to release/18.x (PR #82571)
https://github.com/whentojump milestoned 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] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)
https://github.com/whentojump created https://github.com/llvm/llvm-project/pull/82571 Manually cherry-pick 0bf4f82 and resolve conflicts Closes #82570 >From 37f5e39e1c54ad1c839d80580b9e5303b6e692d3 Mon Sep 17 00:00:00 2001 From: Wentao Zhang <35722712+whentoj...@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:24:31 -0600 Subject: [PATCH] [llvm-cov][CoverageView] minor fix/improvement to HTML and text coverage output (#80952) 1. add the missing condition for MC/DC in hasSubViews() 2. add style for selected line 3. remove name="Ln" attribute in the link within MC/DC views 4. remove color for \n (cherry picked from commit 0bf4f82f661817c79bd538c82c99515837cf1cf8) --- llvm/test/tools/llvm-cov/mcdc-general-none.test | 2 +- llvm/test/tools/llvm-cov/mcdc-general.test | 2 +- llvm/tools/llvm-cov/SourceCoverageView.cpp | 2 +- llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 9 + llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/llvm/test/tools/llvm-cov/mcdc-general-none.test b/llvm/test/tools/llvm-cov/mcdc-general-none.test index bcf8f3cbd05d45e..a373075cc5e37cc 100644 --- a/llvm/test/tools/llvm-cov/mcdc-general-none.test +++ b/llvm/test/tools/llvm-cov/mcdc-general-none.test @@ -52,7 +52,7 @@ // Test html output. // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-general.cpp -format html -o %t.html.dir // RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s -// HTML-COUNT-4: MC/DC Decision Region ( +// HTML-COUNT-4: MC/DC Decision Region ( // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s // HTML-INDEX-LABEL: diff --git a/llvm/test/tools/llvm-cov/mcdc-general.test b/llvm/test/tools/llvm-cov/mcdc-general.test index 588aed09c16a5e3..ded2f3eb1c9a5d3 100644 --- a/llvm/test/tools/llvm-cov/mcdc-general.test +++ b/llvm/test/tools/llvm-cov/mcdc-general.test @@ -118,7 +118,7 @@ // Test html output. // RUN: llvm-cov show --show-mcdc-summary --show-mcdc %S/Inputs/mcdc-general.o -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs %S/Inputs/mcdc-general.cpp -format html -o %t.html.dir // RUN: FileCheck -check-prefix=HTML -input-file=%t.html.dir/coverage/tmp/mcdc-general.cpp.html %s -// HTML-COUNT-4: MC/DC Decision Region ( +// HTML-COUNT-4: MC/DC Decision Region ( // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s // HTML-INDEX-LABEL: diff --git a/llvm/tools/llvm-cov/SourceCoverageView.cpp b/llvm/tools/llvm-cov/SourceCoverageView.cpp index 71edd5fec4280a6..5b85d7d86bfb946 100644 --- a/llvm/tools/llvm-cov/SourceCoverageView.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageView.cpp @@ -139,7 +139,7 @@ bool SourceCoverageView::shouldRenderRegionMarkers( bool SourceCoverageView::hasSubViews() const { return !ExpansionSubViews.empty() || !InstantiationSubViews.empty() || - !BranchSubViews.empty(); + !BranchSubViews.empty() || !MCDCSubViews.empty(); } std::unique_ptr diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp index abc4c49ecae98e3..b93d8cb035306b7 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -246,6 +246,9 @@ tr:hover { tr:last-child { border-bottom: none; } +tr:has(> td >a:target) > td.code > pre { + background-color: #ffa; +} )"; const char *EndHeader = ""; @@ -990,15 +993,13 @@ void SourceCoverageViewHTML::renderMCDCView(raw_ostream &OS, MCDCView &MRV, std::string ColNoStr = Twine(DecisionRegion.ColumnStart).str(); std::string TargetName = "L" + LineNoStr; OS << tag("span", - a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr), -TargetName), + a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)), "line-number") + ") to ("; LineNoStr = utostr(uint64_t(DecisionRegion.LineEnd)); ColNoStr = utostr(uint64_t(DecisionRegion.ColumnEnd)); OS << tag("span", - a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr), -TargetName), + a("#" + TargetName, tag("span", LineNoStr + ":" + ColNoStr)), "line-number") + ")\n\n"; diff --git a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp index 73b7ffe16a9637e..580da45ecfc0d83 100644 --- a/llvm/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageViewText.cpp @@ -382,7 +382,8 @@ void SourceCoverageViewText::renderMCDCView(raw_ostream &OS, MCDCView &MRV, colored_ostream(OS, raw_ostream::RED, getOptions().Colors && Record.getPercentCovered() < 100.0, /*Bold=*/false, /*BG=*/true)
[llvm-branch-commits] [llvm] Backport 0bf4f82 to release/18.x (PR #82571)
https://github.com/whentojump edited 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][CoverageMapping] do not emit a gap region when either end doesn't have valid source locations (#89564) (PR #90369)
whentojump wrote: > Hi @whentojump (or anyone else). If you would like to add a note about this > fix in the release notes (completely optional). Please reply to this comment > with a one or two sentence description of the fix. When you are done, please > add the release:note label to this PR. Fixes a Clang assertion failure caused by emitting gap coverage mapping regions between statements with . https://github.com/llvm/llvm-project/pull/90369 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits