1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[libFuzzer] improve support for inline-8bit-counters (make it more correct and faster)

llvm-svn: 309443
This commit is contained in:
Kostya Serebryany 2017-07-28 22:00:56 +00:00
parent 7fb96365c5
commit 0b6cd623bd
3 changed files with 21 additions and 3 deletions

View File

@ -309,6 +309,14 @@ static size_t InternalStrnlen2(const char *S1, const char *S2) {
return Len;
}
void TracePC::ClearInlineCounters() {
for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {
uint8_t *Beg = ModuleCounters[i].Start;
size_t Size = ModuleCounters[i].Stop - Beg;
memset(Beg, 0, Size);
}
}
} // namespace fuzzer
extern "C" {
@ -344,6 +352,10 @@ void __sanitizer_cov_8bit_counters_init(uint8_t *Start, uint8_t *Stop) {
fuzzer::TPC.HandleInline8bitCountersInit(Start, Stop);
}
ATTRIBUTE_INTERFACE
void __sanitizer_cov_pcs_init(const uint8_t *pcs_beg, const uint8_t *pcs_end) {
}
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
void __sanitizer_cov_trace_pc_indir(uintptr_t Callee) {

View File

@ -87,8 +87,11 @@ class TracePC {
ValueProfileMap.Reset();
memset(Counters(), 0, GetNumPCs());
ClearExtraCounters();
ClearInlineCounters();
}
void ClearInlineCounters();
void UpdateFeatureSet(size_t CurrentElementIdx, size_t CurrentElementSize);
void PrintFeatureSet();
@ -201,8 +204,11 @@ void TracePC::CollectFeatures(Callback HandleFeature) const {
};
size_t FirstFeature = 0;
ForEachNonZeroByte(Counters, Counters + N, FirstFeature, Handle8bitCounter);
FirstFeature += N * 8;
if (!NumInline8bitCounters) {
ForEachNonZeroByte(Counters, Counters + N, FirstFeature, Handle8bitCounter);
FirstFeature += N * 8;
}
for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {
ForEachNonZeroByte(ModuleCounters[i].Start, ModuleCounters[i].Stop,
FirstFeature, Handle8bitCounter);

View File

@ -3,7 +3,7 @@
UNSUPPORTED: windows
CHECK: BINGO
RUN: not LLVMFuzzer-MemcmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s
RUN: not LLVMFuzzer-MemcmpTest -seed=1 -runs=10000000 2>&1 | FileCheck %s
RUN: not LLVMFuzzer-StrncmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s
RUN: not LLVMFuzzer-StrcmpTest -seed=1 -runs=2000000 2>&1 | FileCheck %s
RUN: not LLVMFuzzer-StrstrTest -seed=1 -runs=2000000 2>&1 | FileCheck %s