summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorMike Aizatsky <aizatsky@chromium.org>2016-12-17 00:11:48 +0000
committerMike Aizatsky <aizatsky@chromium.org>2016-12-17 00:11:48 +0000
commitf07f9f8b5fa4059ce5749316b9fc30d21ea9abfb (patch)
treec10dc50eb418e5b726c91e6ab395a715bb07ea16 /llvm
parent9529643e644766d3757981a7e76f7c44927c8029 (diff)
downloadbcm5719-llvm-f07f9f8b5fa4059ce5749316b9fc30d21ea9abfb.tar.gz
bcm5719-llvm-f07f9f8b5fa4059ce5749316b9fc30d21ea9abfb.zip
[sancov] skip dead files from computations
Differential Revision: https://reviews.llvm.org/D27863 llvm-svn: 290017
Diffstat (limited to 'llvm')
-rw-r--r--llvm/test/tools/sancov/not_covered_functions.test2
-rw-r--r--llvm/test/tools/sancov/stats.test4
-rw-r--r--llvm/test/tools/sancov/symbolize.test5
-rw-r--r--llvm/test/tools/sancov/symbolize_noskip_dead_files.test29
-rw-r--r--llvm/tools/sancov/sancov.cc56
5 files changed, 70 insertions, 26 deletions
diff --git a/llvm/test/tools/sancov/not_covered_functions.test b/llvm/test/tools/sancov/not_covered_functions.test
index 77f0e6bd8dd..4e0e81a52c2 100644
--- a/llvm/test/tools/sancov/not_covered_functions.test
+++ b/llvm/test/tools/sancov/not_covered_functions.test
@@ -1,5 +1,5 @@
REQUIRES: x86_64-linux
-RUN: sancov -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+RUN: sancov -skip-dead-files=0 -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
RUN: sancov -not-covered-functions %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.1.sancov | FileCheck --check-prefix=CHECK1 --allow-empty %s
CHECK: Inputs{{[/\\]}}foo.cpp:5 foo()
diff --git a/llvm/test/tools/sancov/stats.test b/llvm/test/tools/sancov/stats.test
index 05e712b0bde..030d16a9dc6 100644
--- a/llvm/test/tools/sancov/stats.test
+++ b/llvm/test/tools/sancov/stats.test
@@ -1,9 +1,9 @@
REQUIRES: x86_64-linux
RUN: sancov -print-coverage-stats %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
-CHECK: all-edges: 9
+CHECK: all-edges: 8
CHECK: cov-edges: 5
-CHECK: all-functions: 3
+CHECK: all-functions: 2
CHECK: cov-functions: 2
diff --git a/llvm/test/tools/sancov/symbolize.test b/llvm/test/tools/sancov/symbolize.test
index bc6bfd2ec40..7d0ba3e470a 100644
--- a/llvm/test/tools/sancov/symbolize.test
+++ b/llvm/test/tools/sancov/symbolize.test
@@ -5,11 +5,6 @@ CHECK: {
CHECK-NEXT: "covered-points" : ["4e132b", "4e1472", "4e1520", "4e1553", "4e1586"],
CHECK-NEXT: "binary-hash" : "BB3CDD5045AED83906F6ADCC1C4DAF7E2596A6B5",
CHECK-NEXT: "point-symbol-info" : {
-CHECK-NEXT: "test/tools/sancov/Inputs/foo.cpp" : {
-CHECK-NEXT: "foo()" : {
-CHECK-NEXT: "4e178c" : "5:0"
-CHECK-NEXT: }
-CHECK-NEXT: },
CHECK-NEXT: "test/tools/sancov/Inputs/test.cpp" : {
CHECK-NEXT: "bar(std::string)" : {
CHECK-NEXT: "4e132b" : "12:0"
diff --git a/llvm/test/tools/sancov/symbolize_noskip_dead_files.test b/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
new file mode 100644
index 00000000000..60eff941b00
--- /dev/null
+++ b/llvm/test/tools/sancov/symbolize_noskip_dead_files.test
@@ -0,0 +1,29 @@
+REQUIRES: x86_64-linux
+RUN: sancov -symbolize -skip-dead-files=0 -strip_path_prefix="llvm/" %p/Inputs/test-linux_x86_64 %p/Inputs/test-linux_x86_64.0.sancov | FileCheck %s
+
+CHECK: {
+CHECK-NEXT: "covered-points" : ["4e132b", "4e1472", "4e1520", "4e1553", "4e1586"],
+CHECK-NEXT: "binary-hash" : "BB3CDD5045AED83906F6ADCC1C4DAF7E2596A6B5",
+CHECK-NEXT: "point-symbol-info" : {
+CHECK-NEXT: "test/tools/sancov/Inputs/foo.cpp" : {
+CHECK-NEXT: "foo()" : {
+CHECK-NEXT: "4e178c" : "5:0"
+CHECK-NEXT: }
+CHECK-NEXT: },
+CHECK-NEXT: "test/tools/sancov/Inputs/test.cpp" : {
+CHECK-NEXT: "bar(std::string)" : {
+CHECK-NEXT: "4e132b" : "12:0"
+CHECK-NEXT: },
+CHECK-NEXT: "main" : {
+CHECK-NEXT: "4e1472" : "14:0",
+CHECK-NEXT: "4e14c2" : "16:9",
+CHECK-NEXT: "4e1520" : "17:5",
+CHECK-NEXT: "4e1553" : "17:5",
+CHECK-NEXT: "4e1586" : "17:5",
+CHECK-NEXT: "4e1635" : "19:1",
+CHECK-NEXT: "4e1690" : "17:5"
+CHECK-NEXT: }
+CHECK-NEXT: }
+CHECK-NEXT: }
+CHECK-NEXT:}
+
diff --git a/llvm/tools/sancov/sancov.cc b/llvm/tools/sancov/sancov.cc
index 2fbbad11a50..3513d1e6e22 100644
--- a/llvm/tools/sancov/sancov.cc
+++ b/llvm/tools/sancov/sancov.cc
@@ -101,6 +101,10 @@ static cl::list<std::string>
static cl::opt<bool> ClDemangle("demangle", cl::init(true),
cl::desc("Print demangled function name."));
+static cl::opt<bool>
+ ClSkipDeadFiles("skip-dead-files", cl::init(true),
+ cl::desc("Do not list dead source files in reports."));
+
static cl::opt<std::string> ClStripPathPrefix(
"strip_path_prefix", cl::init(""),
cl::desc("Strip this prefix from file paths in reports."));
@@ -609,16 +613,35 @@ private:
static std::vector<CoveragePoint>
getCoveragePoints(const std::string &ObjectFile,
- const std::set<uint64_t> &Addrs, bool InlinedCode) {
+ const std::set<uint64_t> &Addrs,
+ const std::set<uint64_t> &CoveredAddrs) {
std::vector<CoveragePoint> Result;
auto Symbolizer(createSymbolizer());
Blacklists B;
+ std::set<std::string> CoveredFiles;
+ if (ClSkipDeadFiles) {
+ for (auto Addr : CoveredAddrs) {
+ auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);
+ failIfError(LineInfo);
+ CoveredFiles.insert(LineInfo->FileName);
+ auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);
+ failIfError(InliningInfo);
+ for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {
+ auto FrameInfo = InliningInfo->getFrame(I);
+ CoveredFiles.insert(FrameInfo.FileName);
+ }
+ }
+ }
+
for (auto Addr : Addrs) {
std::set<DILineInfo> Infos; // deduplicate debug info.
auto LineInfo = Symbolizer->symbolizeCode(ObjectFile, Addr);
failIfError(LineInfo);
+ if (ClSkipDeadFiles &&
+ CoveredFiles.find(LineInfo->FileName) == CoveredFiles.end())
+ continue;
LineInfo->FileName = normalizeFilename(LineInfo->FileName);
if (B.isBlacklisted(*LineInfo))
continue;
@@ -628,18 +651,19 @@ getCoveragePoints(const std::string &ObjectFile,
Infos.insert(*LineInfo);
Point.Locs.push_back(*LineInfo);
- if (InlinedCode) {
- auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);
- failIfError(InliningInfo);
- for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {
- auto FrameInfo = InliningInfo->getFrame(I);
- FrameInfo.FileName = normalizeFilename(FrameInfo.FileName);
- if (B.isBlacklisted(FrameInfo))
- continue;
- if (Infos.find(FrameInfo) == Infos.end()) {
- Infos.insert(FrameInfo);
- Point.Locs.push_back(FrameInfo);
- }
+ auto InliningInfo = Symbolizer->symbolizeInlinedCode(ObjectFile, Addr);
+ failIfError(InliningInfo);
+ for (uint32_t I = 0; I < InliningInfo->getNumberOfFrames(); ++I) {
+ auto FrameInfo = InliningInfo->getFrame(I);
+ if (ClSkipDeadFiles &&
+ CoveredFiles.find(FrameInfo.FileName) == CoveredFiles.end())
+ continue;
+ FrameInfo.FileName = normalizeFilename(FrameInfo.FileName);
+ if (B.isBlacklisted(FrameInfo))
+ continue;
+ if (Infos.find(FrameInfo) == Infos.end()) {
+ Infos.insert(FrameInfo);
+ Point.Locs.push_back(FrameInfo);
}
}
@@ -926,7 +950,7 @@ symbolize(const RawCoverage &Data, const std::string ObjectFile) {
Data.Addrs->end())) {
fail("Coverage points in binary and .sancov file do not match.");
}
- Coverage->Points = getCoveragePoints(ObjectFile, AllAddrs, true);
+ Coverage->Points = getCoveragePoints(ObjectFile, AllAddrs, *Data.Addrs);
return Coverage;
}
@@ -1134,10 +1158,6 @@ readSymbolizeAndMergeCmdArguments(std::vector<std::string> FileNames) {
// Read raw coverage and symbolize it.
for (const auto &Pair : CoverageByObjFile) {
if (findSanitizerCovFunctions(Pair.first).empty()) {
- for (const auto &FileName : Pair.second) {
- CovFiles.erase(FileName);
- }
-
errs()
<< "Ignoring " << Pair.first
<< " and its coverage because __sanitizer_cov* functions were not "
OpenPOWER on IntegriCloud