Skip to content

Conversation

@ZequanWu
Copy link
Contributor

@ZequanWu ZequanWu commented Sep 7, 2024

Relax the condition to ignore the case when count is 0.

This fixes a bug on 381e9d2. This was reported at https://discourse.llvm.org/t/coverage-from-multiple-test-executables/81024/.

@ZequanWu ZequanWu requested a review from chapuni September 7, 2024 00:21
@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations labels Sep 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2024

@llvm/pr-subscribers-pgo

Author: Zequan Wu (ZequanWu)

Changes

Relax the condition to ignore the case when count is 0.

This fixes a bug on 381e9d2. This was reported at https://discourse.llvm.org/t/coverage-from-multiple-test-executables/81024/.


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

2 Files Affected:

  • (added) compiler-rt/test/profile/instrprof-merging-2.cpp (+54)
  • (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
new file mode 100644
index 00000000000000..4c2579804774f1
--- /dev/null
+++ b/compiler-rt/test/profile/instrprof-merging-2.cpp
@@ -0,0 +1,54 @@
+// UNSUPPORTED: target={{.*windows.*}}
+
+// 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 21ce0ac17d6186..eeef78a822008b 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() && Counts[0] > 0)
+      Record.MappingRegions[0].Count.isZero())
     return Error::success();
 
   MCDCDecisionRecorder MCDCDecisions;

@github-actions
Copy link

github-actions bot commented Sep 7, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@ZequanWu ZequanWu merged commit 6850410 into llvm:main Sep 9, 2024
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx-nvidia-ubuntu running on as-builder-7 while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/180/builds/4778

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/137/231' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-1740620-137-231.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=231 GTEST_SHARD_INDEX=137 /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/0
--
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx-nvidia-ubuntu/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder llvm-nvptx64-nvidia-ubuntu running on as-builder-7 while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/160/builds/4780

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/139/231' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-1918731-139-231.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=231 GTEST_SHARD_INDEX=139 /home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/2
--
/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/home/buildbot/worker/as-builder-7/ramdisk/llvm-nvptx64-nvidia-ubuntu/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-devrel-x86-64 running on ml-opt-devrel-x86-64-b2 while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/4881

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/22/29' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/ml-opt-devrel-x86-64-b1/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-1653782-22-29.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=29 GTEST_SHARD_INDEX=22 /b/ml-opt-devrel-x86-64-b1/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/b/ml-opt-devrel-x86-64-b1/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/1
--
/b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-rel-x86-64 running on ml-opt-rel-x86-64-b1 while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/185/builds/4870

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/21/29' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/ml-opt-rel-x86-64-b1/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-2381224-21-29.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=29 GTEST_SHARD_INDEX=21 /b/ml-opt-rel-x86-64-b1/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/b/ml-opt-rel-x86-64-b1/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/0
--
/b/ml-opt-rel-x86-64-b1/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/b/ml-opt-rel-x86-64-b1/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-win-fast running on as-builder-3 while building compiler-rt,llvm at step 7 "test-build-unified-tree-check-llvm-unit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/2/builds/6294

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm-unit) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests.exe/22/116' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\ProfileData\.\ProfileDataTests.exe-LLVM-Unit-12368-22-116.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=116 GTEST_SHARD_INDEX=22 C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\ProfileData\.\ProfileDataTests.exe
--

Script:
--
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\unittests\ProfileData\.\ProfileDataTests.exe --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/1
--
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\ProfileData\CoverageMappingTest.cpp(746): error: Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\unittests\ProfileData\CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


ZequanWu added a commit that referenced this pull request Sep 9, 2024
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/6574

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/24/58' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-527562-24-58.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=58 GTEST_SHARD_INDEX=24 /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/3
--
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


ZequanWu added a commit that referenced this pull request Sep 9, 2024
Reverts #107661

Breaks llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder lld-x86_64-ubuntu-fast running on as-builder-4 while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/2684

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/22/116' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-1206138-22-116.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=116 GTEST_SHARD_INDEX=22 /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/1
--
/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 9, 2024

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building compiler-rt,llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/8314

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/23/58' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/build/buildbot/premerge-monolithic-linux/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-115007-23-58.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=58 GTEST_SHARD_INDEX=23 /build/buildbot/premerge-monolithic-linux/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/build/buildbot/premerge-monolithic-linux/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/2
--
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 10, 2024

LLVM Buildbot has detected a new failure on builder clang-x86_64-debian-fast running on gribozavr4 while building compiler-rt,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/6891

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/21/116' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/1/clang-x86_64-debian-fast/llvm.obj/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-2850359-21-116.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=116 GTEST_SHARD_INDEX=21 /b/1/clang-x86_64-debian-fast/llvm.obj/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/b/1/clang-x86_64-debian-fast/llvm.obj/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/0
--
/b/1/clang-x86_64-debian-fast/llvm.src/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/b/1/clang-x86_64-debian-fast/llvm.src/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 10, 2024

LLVM Buildbot has detected a new failure on builder llvm-x86_64-debian-dylib running on gribozavr4 while building compiler-rt,llvm at step 7 "test-build-unified-tree-check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/7101

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-llvm) failure: test (failure)
******************** TEST 'LLVM-Unit :: ProfileData/./ProfileDataTests/22/116' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/b/1/llvm-x86_64-debian-dylib/build/unittests/ProfileData/./ProfileDataTests-LLVM-Unit-102541-22-116.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=116 GTEST_SHARD_INDEX=22 /b/1/llvm-x86_64-debian-dylib/build/unittests/ProfileData/./ProfileDataTests
--

Script:
--
/b/1/llvm-x86_64-debian-dylib/build/unittests/ProfileData/./ProfileDataTests --gtest_filter=ParameterizedCovMapTest/CoverageMappingTest.uncovered_function/1
--
/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746: Failure
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0


/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:746
Expected equality of these values:
  2U
    Which is: 2
  Segments.size()
    Which is: 0



********************


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.

4 participants