[PATCH] D27061: [asan] Avoid duplicate and redundant poisoning checks in __sanitizer_contiguous_container_find_bad_address

Ivan Baravy via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 11:30:25 PST 2016


i.baravy updated this revision to Diff 79131.
i.baravy added a comment.

Merge cycles for adjacent regions.


Repository:
  rL LLVM

https://reviews.llvm.org/D27061

Files:
  lib/asan/asan_poisoning.cc


Index: lib/asan/asan_poisoning.cc
===================================================================
--- lib/asan/asan_poisoning.cc
+++ lib/asan/asan_poisoning.cc
@@ -412,20 +412,17 @@
   // ending with end.
   uptr kMaxRangeToCheck = 32;
   uptr r1_beg = beg;
-  uptr r1_end = Min(end + kMaxRangeToCheck, mid);
-  uptr r2_beg = Max(beg, mid - kMaxRangeToCheck);
-  uptr r2_end = Min(end, mid + kMaxRangeToCheck);
-  uptr r3_beg = Max(end - kMaxRangeToCheck, mid);
+  uptr r1_end = Min(beg + kMaxRangeToCheck, mid);
+  uptr r2_beg = Max(r1_end, mid - kMaxRangeToCheck/2);
+  uptr r2_end = Min(end, mid + kMaxRangeToCheck/2);
+  uptr r3_beg = Max(r2_end, end - kMaxRangeToCheck);
   uptr r3_end = end;
   for (uptr i = r1_beg; i < r1_end; i++)
     if (AddressIsPoisoned(i))
       return reinterpret_cast<const void *>(i);
-  for (uptr i = r2_beg; i < mid; i++)
+  for (uptr i = r2_beg; i < r2_end; i++)
     if (AddressIsPoisoned(i))
       return reinterpret_cast<const void *>(i);
-  for (uptr i = mid; i < r2_end; i++)
-    if (!AddressIsPoisoned(i))
-      return reinterpret_cast<const void *>(i);
   for (uptr i = r3_beg; i < r3_end; i++)
     if (!AddressIsPoisoned(i))
       return reinterpret_cast<const void *>(i);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27061.79131.patch
Type: text/x-patch
Size: 1228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161123/0438d3a6/attachment.bin>


More information about the llvm-commits mailing list