forked from OSchip/llvm-project
sanitizer: speedup coverage by 33%
Atomic RMW is not necessary in InitializeGuardArray. It is supposed to run when no user code runs. And if user code runs concurrently, then the atomic RMW won't help anyway. So replace it with non-atomic RMW. InitializeGuardArray takes more than 50% of time during re2 fuzzing: real 0m47.215s 51.56% a.out a.out [.] __sanitizer_reset_coverage 6.68% a.out a.out [.] __sanitizer_cov 3.41% a.out a.out [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long) 1.79% a.out a.out [.] __asan::Allocator::Allocate(unsigned long, unsigned long, With this change: real 0m31.661s 26.21% a.out a.out [.] sanitizer_reset_coverage 10.12% a.out a.out [.] sanitizer_cov 5.38% a.out a.out [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long) 2.53% a.out a.out [.] __asan::Allocator::Allocate(unsigned long, unsigned long, That's 33% speedup. Reviewed in http://reviews.llvm.org/D14537 llvm-svn: 252715
This commit is contained in:
parent
56e3fefbdc
commit
e38d3c8f9f
|
|
@ -226,7 +226,8 @@ void CoverageData::InitializeGuardArray(s32 *guards) {
|
|||
Enable(); // Make sure coverage is enabled at this point.
|
||||
s32 n = guards[0];
|
||||
for (s32 j = 1; j <= n; j++) {
|
||||
uptr idx = atomic_fetch_add(&pc_array_index, 1, memory_order_relaxed);
|
||||
uptr idx = atomic_load_relaxed(&pc_array_index);
|
||||
atomic_store_relaxed(&pc_array_index, idx + 1);
|
||||
guards[j] = -static_cast<s32>(idx + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue