[Sanitizers] Re-apply the fix ordering initialization of coverage and guard arrays

Original commit: http://reviews.llvm.org/rL226440
Related review: http://reviews.llvm.org/D6892

llvm-svn: 227789
This commit is contained in:
Viktor Kutuzov 2015-02-02 09:38:10 +00:00
parent 104949df73
commit 7891c8c173
1 changed files with 3 additions and 1 deletions

View File

@ -157,7 +157,8 @@ void CoverageData::Init() {
}
void CoverageData::Enable() {
CHECK_EQ(pc_array, nullptr);
if (pc_array)
return;
pc_array = reinterpret_cast<uptr *>(
MmapNoReserveOrDie(sizeof(uptr) * kPcArrayMaxSize, "CovInit"));
atomic_store(&pc_array_index, 0, memory_order_relaxed);
@ -183,6 +184,7 @@ void CoverageData::Enable() {
}
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);