diff options
author | Kostya Serebryany <kcc@google.com> | 2016-10-25 02:04:43 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-10-25 02:04:43 +0000 |
commit | 3364f907836d50482f77c7def3952b09e99caa97 (patch) | |
tree | 9891c2d477c59f4a0baeb65b8066650d183b060c /llvm/lib/Fuzzer/FuzzerTracePC.cpp | |
parent | 7695cb6da8021ef610ffbcf3b296a16688c7930d (diff) | |
download | bcm5719-llvm-3364f907836d50482f77c7def3952b09e99caa97.tar.gz bcm5719-llvm-3364f907836d50482f77c7def3952b09e99caa97.zip |
[libFuzzer] simplify the code for use_cmp, also use the position hint when available, add a test
llvm-svn: 285049
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerTracePC.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index ddfee218f3b..ed411f1164b 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/lib/Fuzzer/FuzzerTracePC.cpp @@ -272,55 +272,6 @@ void TracePC::HandleCmp(void *PC, T Arg1, T Arg2) { HandleValueProfile(Idx); } -void TracePC::ProcessTORC(Dictionary *Dict, const uint8_t *Data, size_t Size) { - TORCToDict(TORC8, Dict, Data, Size); - TORCToDict(TORC4, Dict, Data, Size); -} - -template <class T> -void TracePC::TORCToDict(const TableOfRecentCompares<T, kTORCSize> &TORC, - Dictionary *Dict, const uint8_t *Data, size_t Size) { - ScopedDoingMyOwnMemmem scoped_doing_my_own_memmem; - for (size_t i = 0; i < TORC.kSize; i++) { - T A[2] = {TORC.Table[i][0], TORC.Table[i][1]}; - if (!A[0] && !A[1]) continue; - for (int j = 0; j < 2; j++) - TORCToDict(Dict, A[j], A[!j], Data, Size); - } -} - -template <class T> -void TracePC::TORCToDict(Dictionary *Dict, T FindInData, T Substitute, - const uint8_t *Data, size_t Size) { - if (FindInData == Substitute) return; - if (sizeof(T) == 4) { - uint16_t HigherBytes = Substitute >> sizeof(T) * 4; - if (HigherBytes == 0 || HigherBytes == 0xffff) - TORCToDict(Dict, static_cast<uint16_t>(FindInData), - static_cast<uint16_t>(Substitute), Data, Size); - } - const size_t DataSize = sizeof(T); - const uint8_t *End = Data + Size; - int Attempts = 3; - for (int DoSwap = 0; DoSwap <= 1; DoSwap++) { - for (const uint8_t *Cur = Data; Cur < End && Attempts--; Cur++) { - Cur = (uint8_t *)memmem(Cur, End - Cur, &FindInData, DataSize); - if (!Cur) - break; - size_t Pos = Cur - Data; - Word W(reinterpret_cast<uint8_t *>(&Substitute), sizeof(Substitute)); - DictionaryEntry DE(W, Pos); - // TODO: evict all entries from Dic if it's full. - Dict->push_back(DE); - // Printf("Dict[%zd] TORC%zd %llx => %llx pos %zd\n", Dict->size(), - // sizeof(T), - // (uint64_t)FindInData, (uint64_t)Substitute, Pos); - } - FindInData = Bswap(FindInData); - Substitute = Bswap(Substitute); - } -} - } // namespace fuzzer extern "C" { |