summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerLoop.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-10-14 20:20:33 +0000
committerKostya Serebryany <kcc@google.com>2016-10-14 20:20:33 +0000
commita5f94fb6c9cb447ebf32bef848d81ac867fd1c63 (patch)
tree7517f668bf9bcebd8fec1c80d44e3086426557e2 /llvm/lib/Fuzzer/FuzzerLoop.cpp
parent3ed0f643fc3267b7fbb319e4cb5610e5a7e1ba86 (diff)
downloadbcm5719-llvm-a5f94fb6c9cb447ebf32bef848d81ac867fd1c63.tar.gz
bcm5719-llvm-a5f94fb6c9cb447ebf32bef848d81ac867fd1c63.zip
[libFuzzer] add -trace_cmp=1 (guiding mutations based on the observed CMP instructions). This is a reincarnation of the previously deleted -use_traces, but using a different approach for collecting traces. Still a toy, but at least it scales well. Also fix -merge in trace-pc-guard mode
llvm-svn: 284273
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerLoop.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp
index 32e5536c42f..a8f640307fc 100644
--- a/llvm/lib/Fuzzer/FuzzerLoop.cpp
+++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp
@@ -479,6 +479,9 @@ size_t Fuzzer::RunOne(const uint8_t *Data, size_t Size) {
Res = 1;
}
+ if (Res && Options.UseCmp)
+ TPC.ProcessTORC(MD.GetTraceCmpDictionary(), CurrentUnitData, Size);
+
CheckExitOnSrcPos();
auto TimeOfUnit =
duration_cast<seconds>(UnitStopTime - UnitStartTime).count();
@@ -513,6 +516,8 @@ void Fuzzer::ExecuteCallback(const uint8_t *Data, size_t Size) {
UnitStartTime = system_clock::now();
ResetCounters(); // Reset coverage right before the callback.
TPC.ResetMaps();
+ if (Options.UseCmp)
+ TPC.ResetTORC();
if (Options.UseCounters)
TPC.ResetGuards();
int Res = CB(DataCopy, Size);
@@ -594,15 +599,22 @@ UnitVector Fuzzer::FindExtraUnits(const UnitVector &Initial,
ShuffleCorpus(&Res);
TPC.ResetMaps();
TPC.ResetGuards();
+ Corpus.ResetFeatureSet();
ResetCoverage();
- for (auto &U : Initial)
+ for (auto &U : Initial) {
+ TPC.ResetMaps();
+ TPC.ResetGuards();
RunOne(U);
+ }
Tmp.clear();
- for (auto &U : Res)
+ for (auto &U : Res) {
+ TPC.ResetMaps();
+ TPC.ResetGuards();
if (RunOne(U))
Tmp.push_back(U);
+ }
char Stat[7] = "MIN ";
Stat[3] = '0' + Iter;
OpenPOWER on IntegriCloud