[libFuzzer] simplify the code in TracePC::HandleTrace

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285142 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany 2016-10-25 23:52:25 +00:00
parent f8406aa6a6
commit cbe5db8703
3 changed files with 9 additions and 5 deletions

View File

@ -160,7 +160,6 @@ Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
InitializeTraceState();
assert(!F);
F = this;
TPC.ResetTotalPCCoverage();
TPC.ResetMaps();
TPC.ResetGuards();
ResetCoverage();

View File

@ -35,7 +35,6 @@ void TracePC::HandleTrace(uint32_t *Guard, uintptr_t PC) {
if (Counter == 0) {
if (!PCs[Idx % kNumPCs]) {
AddNewPCID(Idx);
TotalPCCoverage++;
PCs[Idx % kNumPCs] = PC;
}
}
@ -50,6 +49,14 @@ void TracePC::HandleTrace(uint32_t *Guard, uintptr_t PC) {
}
}
size_t TracePC::GetTotalPCCoverage() {
size_t Res = 0;
for (size_t i = 0; i < Min(NumGuards+1, kNumPCs); i++)
if (PCs[i])
Res++;
return Res;
}
void TracePC::HandleInit(uint32_t *Start, uint32_t *Stop) {
if (Start == Stop || *Start) return;
assert(NumModules < sizeof(Modules) / sizeof(Modules[0]));

View File

@ -50,8 +50,7 @@ class TracePC {
void HandleCallerCallee(uintptr_t Caller, uintptr_t Callee);
void HandleValueProfile(size_t Value) { ValueProfileMap.AddValue(Value); }
template <class T> void HandleCmp(void *PC, T Arg1, T Arg2);
size_t GetTotalPCCoverage() { return TotalPCCoverage; }
void ResetTotalPCCoverage() { TotalPCCoverage = 0; }
size_t GetTotalPCCoverage();
void SetUseCounters(bool UC) { UseCounters = UC; }
void SetUseValueProfile(bool VP) { UseValueProfile = VP; }
size_t FinalizeTrace(InputCorpus *C, size_t InputSize, bool Shrink);
@ -95,7 +94,6 @@ class TracePC {
private:
bool UseCounters = false;
bool UseValueProfile = false;
size_t TotalPCCoverage = 0;
static const size_t kMaxNewPCIDs = 1024;
uintptr_t NewPCIDs[kMaxNewPCIDs];