Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions compiler-rt/test/profile/instrprof-merging-2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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;
}
2 changes: 1 addition & 1 deletion llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down