Skip to content

Allow CoverageMapping::getCoverageForFile() to show Branches also outside functions#120416

Merged
chapuni merged 1 commit into
mainfrom
users/chapuni/cov/119952
Dec 18, 2024
Merged

Allow CoverageMapping::getCoverageForFile() to show Branches also outside functions#120416
chapuni merged 1 commit into
mainfrom
users/chapuni/cov/119952

Conversation

@chapuni

@chapuni chapuni commented Dec 18, 2024

Copy link
Copy Markdown
Contributor

Fixes #119952

@chapuni chapuni requested review from evodius96 and ornata December 18, 2024 12:46
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Dec 18, 2024
@llvmbot

llvmbot commented Dec 18, 2024

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-pgo

Author: NAKAMURA Takumi (chapuni)

Changes

Fixes #119952


Full diff: https://github.com/llvm/llvm-project/pull/120416.diff

2 Files Affected:

  • (modified) llvm/lib/ProfileData/Coverage/CoverageMapping.cpp (+1-1)
  • (modified) llvm/test/tools/llvm-cov/branch-macros.cpp (+1-1)
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 119e09187b9080..d51448567539f2 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -1412,7 +1412,7 @@ CoverageData CoverageMapping::getCoverageForFile(StringRef Filename) const {
       }
     // Capture branch regions specific to the function (excluding expansions).
     for (const auto &CR : Function.CountedBranchRegions)
-      if (FileIDs.test(CR.FileID) && (CR.FileID == CR.ExpandedFileID))
+      if (FileIDs.test(CR.FileID))
         FileCoverage.BranchRegions.push_back(CR);
     // Capture MCDC records specific to the function.
     for (const auto &MR : Function.MCDCRecords)
diff --git a/llvm/test/tools/llvm-cov/branch-macros.cpp b/llvm/test/tools/llvm-cov/branch-macros.cpp
index 73042ac397d406..7f3d1e8bffb82a 100644
--- a/llvm/test/tools/llvm-cov/branch-macros.cpp
+++ b/llvm/test/tools/llvm-cov/branch-macros.cpp
@@ -5,7 +5,7 @@
 #define COND1 (a == b)
 #define COND2 (a != b)
 #define COND3 (COND1 && COND2)
-#define COND4 (COND3 ? COND2 : COND1)
+#define COND4 (COND3 ? COND2 : COND1) // CHECK: | Branch ([[@LINE]]:15): [True: 1, False: 2]
 #define MACRO1 COND3
 #define MACRO2 MACRO1
 #define MACRO3 MACRO2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llvm-cov: Branches cannot be seen on macro definitions in source view

3 participants