diff options
| author | Kostya Serebryany <kcc@google.com> | 2016-12-05 23:35:22 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2016-12-05 23:35:22 +0000 |
| commit | fe1094b8115ea8ded42d8d2c3dbcfa9ef32f0a76 (patch) | |
| tree | f6582d9ee06a050be732a36fb79a3e1865be195d /llvm/lib/Fuzzer/FuzzerTracePC.cpp | |
| parent | 392aa108116d372a24e1206f7c043463cca82ca6 (diff) | |
| download | bcm5719-llvm-fe1094b8115ea8ded42d8d2c3dbcfa9ef32f0a76.tar.gz bcm5719-llvm-fe1094b8115ea8ded42d8d2c3dbcfa9ef32f0a76.zip | |
[libFuzzer] refactor the code to allow collecting features in different ways. Also initialize a couple of Fuzzer:: members that might have been used uninitialized :(
llvm-svn: 288731
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerTracePC.cpp')
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.cpp | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index 8d58a6d3a91..d8036edf728 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/lib/Fuzzer/FuzzerTracePC.cpp @@ -59,41 +59,6 @@ void TracePC::PrintModuleInfo() { Printf("\n"); } -size_t TracePC::FinalizeTrace(InputCorpus *C, size_t InputSize, bool Shrink) { - if (!UsingTracePcGuard()) return 0; - size_t Res = 0; - const size_t Step = 8; - assert(reinterpret_cast<uintptr_t>(Counters) % Step == 0); - size_t N = Min(kNumCounters, NumGuards + 1); - N = (N + Step - 1) & ~(Step - 1); // Round up. - for (size_t Idx = 0; Idx < N; Idx += Step) { - uint64_t Bundle = *reinterpret_cast<uint64_t*>(&Counters[Idx]); - if (!Bundle) continue; - for (size_t i = Idx; i < Idx + Step; i++) { - uint8_t Counter = (Bundle >> (i * 8)) & 0xff; - if (!Counter) continue; - Counters[i] = 0; - unsigned Bit = 0; - /**/ if (Counter >= 128) Bit = 7; - else if (Counter >= 32) Bit = 6; - else if (Counter >= 16) Bit = 5; - else if (Counter >= 8) Bit = 4; - else if (Counter >= 4) Bit = 3; - else if (Counter >= 3) Bit = 2; - else if (Counter >= 2) Bit = 1; - size_t Feature = (i * 8 + Bit); - if (C->AddFeature(Feature, InputSize, Shrink)) - Res++; - } - } - if (UseValueProfile) - ValueProfileMap.ForEach([&](size_t Idx) { - if (C->AddFeature(NumGuards + Idx, InputSize, Shrink)) - Res++; - }); - return Res; -} - void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) { const uintptr_t kBits = 12; const uintptr_t kMask = (1 << kBits) - 1; |

