[llvm] r289999 - [libFuzzer] avoid msan false positives in more cases
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 14:45:25 PST 2016
Author: kcc
Date: Fri Dec 16 16:45:25 2016
New Revision: 289999
URL: http://llvm.org/viewvc/llvm-project?rev=289999&view=rev
Log:
[libFuzzer] avoid msan false positives in more cases
Modified:
llvm/trunk/lib/Fuzzer/FuzzerDefs.h
llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
Modified: llvm/trunk/lib/Fuzzer/FuzzerDefs.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerDefs.h?rev=289999&r1=289998&r2=289999&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerDefs.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerDefs.h Fri Dec 16 16:45:25 2016
@@ -44,6 +44,13 @@
#define ATTRIBUTE_TARGET_POPCNT
#endif
+
+#ifdef __clang__ // avoid gcc warning.
+# define ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
+#else
+# define ATTRIBUTE_NO_SANITIZE_MEMORY
+#endif
+
namespace fuzzer {
template <class T> T Min(T a, T b) { return a < b ? a : b; }
Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=289999&r1=289998&r2=289999&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Fri Dec 16 16:45:25 2016
@@ -137,6 +137,7 @@ struct MallocFreeTracer {
static MallocFreeTracer AllocTracer;
+ATTRIBUTE_NO_SANITIZE_MEMORY
void MallocHook(const volatile void *ptr, size_t size) {
size_t N = AllocTracer.Mallocs++;
F->HandleMalloc(size);
@@ -146,6 +147,8 @@ void MallocHook(const volatile void *ptr
EF->__sanitizer_print_stack_trace();
}
}
+
+ATTRIBUTE_NO_SANITIZE_MEMORY
void FreeHook(const volatile void *ptr) {
size_t N = AllocTracer.Frees++;
if (int TraceLevel = AllocTracer.TraceLevel) {
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=289999&r1=289998&r2=289999&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp Fri Dec 16 16:45:25 2016
@@ -198,9 +198,7 @@ void TracePC::PrintCoverage() {
// For cmp instructions the interesting value is a XOR of the parameters.
// The interesting value is mixed up with the PC and is then added to the map.
-#ifdef __clang__ // avoid gcc warning.
-__attribute__((no_sanitize("memory")))
-#endif
+ATTRIBUTE_NO_SANITIZE_MEMORY
void TracePC::AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2,
size_t n) {
if (!n) return;
@@ -218,9 +216,7 @@ void TracePC::AddValueForMemcmp(void *ca
TPC.HandleValueProfile((PC & 4095) | (Idx << 12));
}
-#ifdef __clang__ // avoid gcc warning.
-__attribute__((no_sanitize("memory")))
-#endif
+ATTRIBUTE_NO_SANITIZE_MEMORY
void TracePC::AddValueForStrcmp(void *caller_pc, const char *s1, const char *s2,
size_t n) {
if (!n) return;
More information about the llvm-commits
mailing list