[llvm] r285142 - [libFuzzer] simplify the code in TracePC::HandleTrace
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 16:52:26 PDT 2016
Author: kcc
Date: Tue Oct 25 18:52:25 2016
New Revision: 285142
URL: http://llvm.org/viewvc/llvm-project?rev=285142&view=rev
Log:
[libFuzzer] simplify the code in TracePC::HandleTrace
Modified:
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=285142&r1=285141&r2=285142&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Tue Oct 25 18:52:25 2016
@@ -160,7 +160,6 @@ Fuzzer::Fuzzer(UserCallback CB, InputCor
InitializeTraceState();
assert(!F);
F = this;
- TPC.ResetTotalPCCoverage();
TPC.ResetMaps();
TPC.ResetGuards();
ResetCoverage();
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=285142&r1=285141&r2=285142&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp Tue Oct 25 18:52:25 2016
@@ -35,7 +35,6 @@ void TracePC::HandleTrace(uint32_t *Guar
if (Counter == 0) {
if (!PCs[Idx % kNumPCs]) {
AddNewPCID(Idx);
- TotalPCCoverage++;
PCs[Idx % kNumPCs] = PC;
}
}
@@ -50,6 +49,14 @@ void TracePC::HandleTrace(uint32_t *Guar
}
}
+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]));
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.h?rev=285142&r1=285141&r2=285142&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.h Tue Oct 25 18:52:25 2016
@@ -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];
More information about the llvm-commits
mailing list