Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

chapuni
Copy link
Contributor

@chapuni chapuni commented Dec 18, 2024

Fixes #119952

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

llvmbot commented Dec 18, 2024

@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

@chapuni chapuni merged commit e698079 into main Dec 18, 2024
10 checks passed
@chapuni chapuni deleted the users/chapuni/cov/119952 branch December 18, 2024 23:41
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