diff options
| author | Kostya Serebryany <kcc@google.com> | 2019-06-14 23:29:56 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2019-06-14 23:29:56 +0000 |
| commit | 0feed5d585f75cc6ae5fa5802c096cbbf3cf164c (patch) | |
| tree | 5bc13daf9e36543ae1595109ed7079eafaa458a5 /compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp | |
| parent | 9967a6c60ab365bcb858566c267908b0517d76be (diff) | |
| download | bcm5719-llvm-0feed5d585f75cc6ae5fa5802c096cbbf3cf164c.tar.gz bcm5719-llvm-0feed5d585f75cc6ae5fa5802c096cbbf3cf164c.zip | |
[libFuzzer] in autofocus mode, give more weight to functions with DFT
llvm-svn: 363473
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp')
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp b/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp index c7200a3c26b..99ff918f7c6 100644 --- a/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp @@ -42,11 +42,16 @@ bool BlockCoverage::AppendCoverage(const std::string &S) { bool BlockCoverage::AppendCoverage(std::istream &IN) { std::string L; while (std::getline(IN, L, '\n')) { - if (L.empty() || L[0] != 'C') - continue; // Ignore non-coverage lines. + if (L.empty()) + continue; std::stringstream SS(L.c_str() + 1); size_t FunctionId = 0; SS >> FunctionId; + if (L[0] == 'F') { + FunctionsWithDFT.insert(FunctionId); + continue; + } + if (L[0] != 'C') continue; Vector<uint32_t> CoveredBlocks; while (true) { uint32_t BB = 0; @@ -87,9 +92,12 @@ Vector<double> BlockCoverage::FunctionWeights(size_t NumFunctions) const { auto Counters = It.second; assert(FunctionID < NumFunctions); auto &Weight = Res[FunctionID]; - Weight = 1000.; // this function is covered. + // Give higher weight if the function has a DFT. + Weight = FunctionsWithDFT.count(FunctionID) ? 1000. : 1; + // Give higher weight to functions with less frequently seen basic blocks. Weight /= SmallestNonZeroCounter(Counters); - Weight *= NumberOfUncoveredBlocks(Counters) + 1; // make sure it's not 0. + // Give higher weight to functions with the most uncovered basic blocks. + Weight *= NumberOfUncoveredBlocks(Counters) + 1; } return Res; } |

