From c0d857c24c6cf0ad6bad196b287c50c7fd97d8cc Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Wed, 8 Aug 2018 14:32:46 +0000 Subject: [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@339249 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/fuzzer/FuzzerLoop.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/fuzzer/FuzzerLoop.cpp') diff --git a/lib/fuzzer/FuzzerLoop.cpp b/lib/fuzzer/FuzzerLoop.cpp index 23fcb8a40..c7b13d1e5 100644 --- a/lib/fuzzer/FuzzerLoop.cpp +++ b/lib/fuzzer/FuzzerLoop.cpp @@ -466,16 +466,11 @@ void Fuzzer::CheckForUnstableCounters(const uint8_t *Data, size_t Size) { // 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, -- cgit v1.2.1