[PATCH] [Sanitizers] Order initialization of coverage and guard arrays

Phabricator reviews at reviews.llvm.org
Mon Jan 19 01:43:26 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6892

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc

Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
@@ -156,7 +156,8 @@
 }
 
 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);
@@ -182,6 +183,7 @@
 }
 
 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);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6892.18372.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150119/610b9c34/attachment.bin>


More information about the llvm-commits mailing list