llvm.org GIT mirror llvm / c7ab3c7
[libFuzzer] avoid msan false positives in more cases git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289999 91177308-0d34-0410-b5e6-96231b3b80d8 Kostya Serebryany 3 years ago
3 changed file(s) with 12 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4343 #define ATTRIBUTE_TARGET_POPCNT
4444 #endif
4545
46
47 #ifdef __clang__ // avoid gcc warning.
48 # define ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
49 #else
50 # define ATTRIBUTE_NO_SANITIZE_MEMORY
51 #endif
52
4653 namespace fuzzer {
4754
4855 template T Min(T a, T b) { return a < b ? a : b; }
136136
137137 static MallocFreeTracer AllocTracer;
138138
139 ATTRIBUTE_NO_SANITIZE_MEMORY
139140 void MallocHook(const volatile void *ptr, size_t size) {
140141 size_t N = AllocTracer.Mallocs++;
141142 F->HandleMalloc(size);
145146 EF->__sanitizer_print_stack_trace();
146147 }
147148 }
149
150 ATTRIBUTE_NO_SANITIZE_MEMORY
148151 void FreeHook(const volatile void *ptr) {
149152 size_t N = AllocTracer.Frees++;
150153 if (int TraceLevel = AllocTracer.TraceLevel) {
197197 // For cmp instructions the interesting value is a XOR of the parameters.
198198 // The interesting value is mixed up with the PC and is then added to the map.
199199
200 #ifdef __clang__ // avoid gcc warning.
201 __attribute__((no_sanitize("memory")))
202 #endif
200 ATTRIBUTE_NO_SANITIZE_MEMORY
203201 void TracePC::AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2,
204202 size_t n) {
205203 if (!n) return;
217215 TPC.HandleValueProfile((PC & 4095) | (Idx << 12));
218216 }
219217
220 #ifdef __clang__ // avoid gcc warning.
221 __attribute__((no_sanitize("memory")))
222 #endif
218 ATTRIBUTE_NO_SANITIZE_MEMORY
223219 void TracePC::AddValueForStrcmp(void *caller_pc, const char *s1, const char *s2,
224220 size_t n) {
225221 if (!n) return;