[libFuzzer] Optimize handle unstable checks by reducing iterations
Summary:
We only run the 3rd check if 2nd check finds unstable edges.
3rd UpdateUnstableCounters is now merged with ApplyUnstableCounters to only run 1 iteration.
Patch by Kyungtak Woo (@kevinwkt).
Reviewers: Dor1s, metzman, morehouse
Reviewed By: Dor1s, morehouse
Subscribers: delcypher, #sanitizers, llvm-commits, kcc
Differential Revision: https://reviews.llvm.org/D50411
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer@339249 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/FuzzerLoop.cpp b/FuzzerLoop.cpp
index 23fcb8a..c7b13d1 100644
--- a/FuzzerLoop.cpp
+++ b/FuzzerLoop.cpp
@@ -466,16 +466,11 @@
// First Rerun
CBSetupAndRun();
- TPC.UpdateUnstableCounters(Options.HandleUnstable);
-
- // Second Rerun
- CBSetupAndRun();
- TPC.UpdateUnstableCounters(Options.HandleUnstable);
-
- // Move minimum hit counts back to ModuleInline8bitCounters
- if (Options.HandleUnstable == TracePC::MinUnstable ||
- Options.HandleUnstable == TracePC::ZeroUnstable)
- TPC.ApplyUnstableCounters();
+ if (TPC.UpdateUnstableCounters(Options.HandleUnstable)) {
+ // Second Rerun
+ CBSetupAndRun();
+ TPC.UpdateAndApplyUnstableCounters(Options.HandleUnstable);
+ }
}
bool Fuzzer::RunOne(const uint8_t *Data, size_t Size, bool MayDeleteFile,