[libFuzzer] add -shuffle flag
[oota-llvm.git] / lib / Fuzzer / FuzzerLoop.cpp
index a642bbbf5cba8cd8941f839136929e5b51c0b1f6..ef71407d21cb688653310f2ace97fe13e559ba4e 100644 (file)
@@ -137,11 +137,13 @@ void Fuzzer::ShuffleAndMinimize() {
     Printf("PreferSmall: %d\n", PreferSmall);
   PrintStats("READ  ", 0);
   std::vector<Unit> NewCorpus;
-  std::random_shuffle(Corpus.begin(), Corpus.end(), USF.GetRand());
-  if (PreferSmall)
-    std::stable_sort(
-        Corpus.begin(), Corpus.end(),
-        [](const Unit &A, const Unit &B) { return A.size() < B.size(); });
+  if (Options.ShuffleAtStartUp) {
+    std::random_shuffle(Corpus.begin(), Corpus.end(), USF.GetRand());
+    if (PreferSmall)
+      std::stable_sort(
+          Corpus.begin(), Corpus.end(),
+          [](const Unit &A, const Unit &B) { return A.size() < B.size(); });
+  }
   Unit &U = CurrentUnit;
   for (const auto &C : Corpus) {
     for (size_t First = 0; First < 1; First++) {