[PATCH] D63695: [sancov] Ignore PC samples with value 0

Roland McGrath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 23 15:58:44 PDT 2019


mcgrathr created this revision.
mcgrathr added reviewers: phosek, MaskRay.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The sancov runtime for the (Fuchsia) Zircon kernel delivers results
in the standard format, but as the full array of possible samples
with 0 in uncovered slots.  That runtime delivers "live" data and
has no final "export" pass to compactify out the uncovered slots,
and it seems silly to require another offline tool just for that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63695

Files:
  llvm/tools/sancov/sancov.cpp


Index: llvm/tools/sancov/sancov.cpp
===================================================================
--- llvm/tools/sancov/sancov.cpp
+++ llvm/tools/sancov/sancov.cpp
@@ -131,8 +131,12 @@
 // Contents of .sancov file: list of coverage point addresses that were
 // executed.
 struct RawCoverage {
-  explicit RawCoverage(std::unique_ptr<std::set<uint64_t>> Addrs)
-      : Addrs(std::move(Addrs)) {}
+  explicit RawCoverage(std::unique_ptr<std::set<uint64_t>> RawAddrs)
+      : Addrs(std::move(RawAddrs)) {
+    // Ignore slots that are zero, so a runtime implementation is not required
+    // to compactify the data.
+    Addrs->erase(0);
+  }
 
   // Read binary .sancov file.
   static ErrorOr<std::unique_ptr<RawCoverage>>
@@ -1231,7 +1235,7 @@
   llvm::InitializeAllTargetMCs();
   llvm::InitializeAllDisassemblers();
 
-  cl::ParseCommandLineOptions(Argc, Argv, 
+  cl::ParseCommandLineOptions(Argc, Argv,
       "Sanitizer Coverage Processing Tool (sancov)\n\n"
       "  This tool can extract various coverage-related information from: \n"
       "  coverage-instrumented binary files, raw .sancov files and their "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63695.206142.patch
Type: text/x-patch
Size: 1129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190623/09820d33/attachment.bin>


More information about the llvm-commits mailing list