Skip to content

Conversation

@ZequanWu
Copy link
Contributor

@ZequanWu ZequanWu commented Sep 9, 2024

Reverts #107661

Breaks llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp

@ZequanWu ZequanWu merged commit a7c26aa into main Sep 9, 2024
@ZequanWu ZequanWu deleted the revert-107661-fix-missing-cov branch September 9, 2024 18:34
@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations labels Sep 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 9, 2024

@llvm/pr-subscribers-pgo

Author: Zequan Wu (ZequanWu)

Changes

Reverts llvm/llvm-project#107661

Breaks llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp


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

2 Files Affected:

  • (removed) compiler-rt/test/profile/instrprof-merging-2.cpp (-55)
  • (modified) llvm/lib/ProfileData/Coverage/CoverageMapping.cpp (+1-1)
diff --git a/compiler-rt/test/profile/instrprof-merging-2.cpp b/compiler-rt/test/profile/instrprof-merging-2.cpp
deleted file mode 100644
index 438394f9fb239e..00000000000000
--- a/compiler-rt/test/profile/instrprof-merging-2.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// UNSUPPORTED: target={{.*windows.*}}
-
-// clang-format off
-// RUN: split-file %s %t
-// RUN: %clangxx_profgen -fcoverage-mapping %t/test1.cpp -o %t/test1.exe
-// RUN: %clangxx_profgen -fcoverage-mapping %t/test2.cpp -o %t/test2.exe
-// RUN: env LLVM_PROFILE_FILE=%t/test1.profraw %run %t/test1.exe
-// RUN: env LLVM_PROFILE_FILE=%t/test2.profraw %run %t/test2.exe
-// RUN: llvm-profdata merge %t/test1.profraw %t/test2.profraw -o %t/merged.profdata
-// RUN: llvm-cov show -instr-profile=%t/merged.profdata -object %t/test1.exe %t/test2.exe | FileCheck %s
-// RUN: llvm-cov show -instr-profile=%t/merged.profdata -object %t/test2.exe %t/test1.exe | FileCheck %s
-
-// CHECK:       |struct Test {
-// CHECK-NEXT: 1|  int getToTest() {
-// CHECK-NEXT: 2|    for (int i = 0; i < 1; i++) {
-// CHECK-NEXT: 1|      if (false) {
-// CHECK-NEXT: 0|        return 1;
-// CHECK-NEXT: 0|      }
-// CHECK-NEXT: 1|    }
-// CHECK-NEXT: 1|    if (true) {
-// CHECK-NEXT: 1|      return 1;
-// CHECK-NEXT: 1|    }
-// CHECK-NEXT: 0|    return 1;
-// CHECK-NEXT: 1|  }
-// CHECK-NEXT:  |};
-// CHECK-NEXT:  |
-
-#--- test.h
-struct Test {
-  int getToTest() {
-    for (int i = 0; i < 1; i++) {
-      if (false) {
-        return 1;
-      }
-    }
-    if (true) {
-      return 1;
-    }
-    return 1;
-  }
-};
-
-#--- test1.cpp
-#include "test.h"
-int main() {
-  Test t;
-  t.getToTest();
-  return 0;
-}
-
-#--- test2.cpp
-#include "test.h"
-int main() {
-  return 0;
-}
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index acb7dd922ab9fa..18643c6b44485e 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -851,7 +851,7 @@ Error CoverageMapping::loadFunctionRecord(
   // won't (in which case we don't unintuitively report functions as uncovered
   // when they have non-zero counts in the profile).
   if (Record.MappingRegions.size() == 1 &&
-      Record.MappingRegions[0].Count.isZero())
+      Record.MappingRegions[0].Count.isZero() && Counts[0] > 0)
     return Error::success();
 
   MCDCDecisionRecorder MCDCDecisions;

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

Labels

compiler-rt PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants