[llvm-cov] Improve error messaging for function mismatches
Passing "-dump" to llvm-cov will now print more detailed information
about function hash and counter mismatches. This should make it easier
to debug *.profdata files which contain incorrect records, and to debug
other scenarios where coverage goes missing due to mismatch issues.
llvm-svn: 313853
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 09ee82a..981c93a 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -350,9 +350,23 @@
}
auto Coverage = std::move(CoverageOrErr.get());
unsigned Mismatched = Coverage->getMismatchedCount();
- if (Mismatched)
+ if (Mismatched) {
warning(utostr(Mismatched) + " functions have mismatched data");
+ if (ViewOpts.Debug) {
+ for (const auto &HashMismatch : Coverage->getHashMismatches())
+ errs() << "hash-mismatch: "
+ << "No profile record found for '" << HashMismatch.first << "'"
+ << " with hash = 0x" << utohexstr(HashMismatch.second) << "\n";
+
+ for (const auto &CounterMismatch : Coverage->getCounterMismatches())
+ errs() << "counter-mismatch: "
+ << "Coverage mapping for " << CounterMismatch.first
+ << " only has " << CounterMismatch.second
+ << " valid counter expressions\n";
+ }
+ }
+
remapPathNames(*Coverage);
if (!SourceFiles.empty())