[llvm] r283979 - Revert "[libFuzzer] refactoring to speed things up, NFC"
Daniel Jasper via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 00:26:47 PDT 2016
Author: djasper
Date: Wed Oct 12 02:26:46 2016
New Revision: 283979
URL: http://llvm.org/viewvc/llvm-project?rev=283979&view=rev
Log:
Revert "[libFuzzer] refactoring to speed things up, NFC"
This reverts commit r283946.
This breaks when build with GCC:
lib/Fuzzer/FuzzerTracePC.cpp:169:6: error: always_inline function might not be inlinable [-Werror=attributes]
lib/Fuzzer/FuzzerTracePC.cpp:169:6: error: inlining failed in call to always_inline 'void fuzzer::TracePC::HandleCmp(void*, T, T) [with T = long unsigned int]': target specific option mismatch
lib/Fuzzer/FuzzerTracePC.cpp:198:65: error: called from here
Modified:
llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=283979&r1=283978&r2=283979&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp Wed Oct 12 02:26:46 2016
@@ -64,7 +64,7 @@ void TracePC::PrintModuleInfo() {
void TracePC::ResetGuards() {
uint32_t N = 0;
for (size_t M = 0; M < NumModules; M++)
- for (uint32_t *X = Modules[M].Start, *End = Modules[M].Stop; X < End; X++)
+ for (uint32_t *X = Modules[M].Start; X < Modules[M].Stop; X++)
*X = ++N;
assert(N == NumGuards);
}
@@ -163,16 +163,24 @@ void TracePC::AddValueForStrcmp(void *ca
TPC.HandleValueProfile((PC & 4095) | (Idx << 12));
}
-template <class T>
ATTRIBUTE_TARGET_POPCNT
-__attribute__((always_inline))
-void TracePC::HandleCmp(void *PC, T Arg1, T Arg2) {
- uintptr_t PCuint = reinterpret_cast<uintptr_t>(PC);
+static void AddValueForCmp(void *PCptr, uint64_t Arg1, uint64_t Arg2) {
+ uintptr_t PC = reinterpret_cast<uintptr_t>(PCptr);
uint64_t ArgDistance = __builtin_popcountl(Arg1 ^ Arg2) + 1; // [1,65]
- uintptr_t Idx = ((PCuint & 4095) + 1) * ArgDistance;
+ uintptr_t Idx = ((PC & 4095) + 1) * ArgDistance;
TPC.HandleValueProfile(Idx);
}
+static void AddValueForSingleVal(void *PCptr, uintptr_t Val) {
+ if (!Val) return;
+ uintptr_t PC = reinterpret_cast<uintptr_t>(PCptr);
+ uint64_t ArgDistance = __builtin_popcountl(Val) - 1; // [0,63]
+ uintptr_t Idx = (PC & 4095) | (ArgDistance << 12);
+ TPC.HandleValueProfile(Idx);
+}
+
+
+
} // namespace fuzzer
extern "C" {
@@ -193,21 +201,28 @@ void __sanitizer_cov_trace_pc_indir(uint
fuzzer::TPC.HandleCallerCallee(PC, Callee);
}
+// TODO: this one will not be used with the newest clang. Remove it.
+__attribute__((visibility("default")))
+void __sanitizer_cov_trace_cmp(uint64_t SizeAndType, uint64_t Arg1,
+ uint64_t Arg2) {
+ fuzzer::AddValueForCmp(__builtin_return_address(0), Arg1, Arg2);
+}
+
__attribute__((visibility("default")))
-void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Arg1, Arg2);
+void __sanitizer_cov_trace_cmp8(uint64_t Arg1, int64_t Arg2) {
+ fuzzer::AddValueForCmp(__builtin_return_address(0), Arg1, Arg2);
}
__attribute__((visibility("default")))
-void __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Arg1, Arg2);
+void __sanitizer_cov_trace_cmp4(uint32_t Arg1, int32_t Arg2) {
+ fuzzer::AddValueForCmp(__builtin_return_address(0), Arg1, Arg2);
}
__attribute__((visibility("default")))
-void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Arg1, Arg2);
+void __sanitizer_cov_trace_cmp2(uint16_t Arg1, int16_t Arg2) {
+ fuzzer::AddValueForCmp(__builtin_return_address(0), Arg1, Arg2);
}
__attribute__((visibility("default")))
-void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Arg1, Arg2);
+void __sanitizer_cov_trace_cmp1(uint8_t Arg1, int8_t Arg2) {
+ fuzzer::AddValueForCmp(__builtin_return_address(0), Arg1, Arg2);
}
__attribute__((visibility("default")))
@@ -217,20 +232,20 @@ void __sanitizer_cov_trace_switch(uint64
char *PC = (char*)__builtin_return_address(0);
for (size_t i = 0; i < N; i++)
if (Val != Vals[i])
- fuzzer::TPC.HandleCmp(PC + i, Val, Vals[i]);
+ fuzzer::AddValueForCmp(PC + i, Val, Vals[i]);
}
__attribute__((visibility("default")))
void __sanitizer_cov_trace_div4(uint32_t Val) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Val, (uint32_t)0);
+ fuzzer::AddValueForSingleVal(__builtin_return_address(0), Val);
}
__attribute__((visibility("default")))
void __sanitizer_cov_trace_div8(uint64_t Val) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Val, (uint64_t)0);
+ fuzzer::AddValueForSingleVal(__builtin_return_address(0), Val);
}
__attribute__((visibility("default")))
void __sanitizer_cov_trace_gep(uintptr_t Idx) {
- fuzzer::TPC.HandleCmp(__builtin_return_address(0), Idx, (uintptr_t)0);
+ fuzzer::AddValueForSingleVal(__builtin_return_address(0), Idx);
}
} // extern "C"
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.h?rev=283979&r1=283978&r2=283979&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.h Wed Oct 12 02:26:46 2016
@@ -25,7 +25,6 @@ class TracePC {
void HandleInit(uint32_t *start, uint32_t *stop);
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; }
void SetUseCounters(bool UC) { UseCounters = UC; }
@@ -33,7 +32,8 @@ class TracePC {
size_t FinalizeTrace(InputCorpus *C, size_t InputSize, bool Shrink);
bool UpdateValueProfileMap(ValueBitMap *MaxValueProfileMap) {
return UseValueProfile && MaxValueProfileMap->MergeFrom(ValueProfileMap);
- }
+ }
+
size_t GetNewPCIDs(uintptr_t **NewPCIDsPtr) {
*NewPCIDsPtr = NewPCIDs;
More information about the llvm-commits
mailing list