[llvm] r237649 - [lib/Fuzzer] more efficient reload logic; also don't spam git too much

Kostya Serebryany kcc at google.com
Mon May 18 18:06:07 PDT 2015


Author: kcc
Date: Mon May 18 20:06:07 2015
New Revision: 237649

URL: http://llvm.org/viewvc/llvm-project?rev=237649&view=rev
Log:
[lib/Fuzzer] more efficient reload logic; also don't spam git too much

Modified:
    llvm/trunk/lib/Fuzzer/FuzzerInternal.h
    llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
    llvm/trunk/lib/Fuzzer/pull_and_push_fuzz_corpus.sh

Modified: llvm/trunk/lib/Fuzzer/FuzzerInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerInternal.h?rev=237649&r1=237648&r2=237649&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerInternal.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerInternal.h Mon May 18 20:06:07 2015
@@ -16,7 +16,6 @@
 #include <string>
 #include <vector>
 #include <unordered_set>
-#include <set>
 
 #include "FuzzerInterface.h"
 
@@ -132,7 +131,7 @@ class Fuzzer {
   size_t TotalNumberOfRuns = 0;
 
   std::vector<Unit> Corpus;
-  std::set<Unit> UnitsAddedAfterInitialLoad;
+  std::unordered_set<std::string> UnitHashesAddedToCorpus;
   std::unordered_set<uintptr_t> FullCoverageSets;
   std::unordered_set<uint64_t>  CoveragePairs;
 

Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=237649&r1=237648&r2=237649&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Mon May 18 20:06:07 2015
@@ -99,13 +99,15 @@ void Fuzzer::RereadOutputCorpus() {
   for (auto &X : AdditionalCorpus) {
     if (X.size() > (size_t)Options.MaxLen)
       X.resize(Options.MaxLen);
-    if (UnitsAddedAfterInitialLoad.insert(X).second) {
-      Corpus.push_back(X);
+    if (UnitHashesAddedToCorpus.insert(Hash(X)).second) {
       CurrentUnit.clear();
       CurrentUnit.insert(CurrentUnit.begin(), X.begin(), X.end());
       size_t NewCoverage = RunOne(CurrentUnit);
-      if (NewCoverage && Options.Verbosity >= 1)
-        PrintStats("RELOAD", NewCoverage);
+      if (NewCoverage) {
+        Corpus.push_back(X);
+        if (Options.Verbosity >= 1)
+          PrintStats("RELOAD", NewCoverage);
+      }
     }
   }
 }
@@ -142,6 +144,8 @@ void Fuzzer::ShuffleAndMinimize() {
     }
   }
   Corpus = NewCorpus;
+  for (auto &X : Corpus)
+    UnitHashesAddedToCorpus.insert(Hash(X));
   PrintStats("INITED", MaxCov);
 }
 
@@ -292,7 +296,7 @@ void Fuzzer::SaveCorpus() {
 void Fuzzer::ReportNewCoverage(size_t NewCoverage, const Unit &U) {
   if (!NewCoverage) return;
   Corpus.push_back(U);
-  UnitsAddedAfterInitialLoad.insert(U);
+  UnitHashesAddedToCorpus.insert(Hash(U));
   PrintStats("NEW   ", NewCoverage, "");
   if (Options.Verbosity) {
     std::cerr << " L: " << U.size();

Modified: llvm/trunk/lib/Fuzzer/pull_and_push_fuzz_corpus.sh
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/pull_and_push_fuzz_corpus.sh?rev=237649&r1=237648&r2=237649&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/pull_and_push_fuzz_corpus.sh (original)
+++ llvm/trunk/lib/Fuzzer/pull_and_push_fuzz_corpus.sh Mon May 18 20:06:07 2015
@@ -9,7 +9,7 @@ cd $1
 git add *
 git commit -m "fuzz test corpus"
 git pull --no-edit
-for((attempt=0; attempt<100; attempt++)); do
+for((attempt=0; attempt<5; attempt++)); do
   echo GIT PUSH $1 ATTEMPT $attempt
   if $(git push); then break; fi
   git pull --no-edit





More information about the llvm-commits mailing list