[PATCH] D36430: [asan] Restore dead-code-elimination optimization for Fuchsia

Roland McGrath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 14:43:19 PDT 2017

mcgrathr created this revision.
mcgrathr added a project: Sanitizers.
Herald added a subscriber: kubamracek.

r310244 fixed a bug introduced by r309914 for non-Fuchsia builds.
In doing so it also reversed the intended effect of the change for
Fuchsia builds, which was to allow all the AllocateFromLocalPool
code and its variables to be optimized away entirely.

This change restores that optimization for Fuchsia builds, but
doesn't have the original change's bug because the comparison
arithmetic now takes into account the size of the elements.




Index: lib/asan/asan_malloc_linux.cc
--- lib/asan/asan_malloc_linux.cc
+++ lib/asan/asan_malloc_linux.cc
@@ -32,7 +32,7 @@
 static INLINE bool IsInDlsymAllocPool(const void *ptr) {
   uptr off = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
-  return off < sizeof(alloc_memory_for_dlsym);
+  return off < allocated_for_dlsym * sizeof(alloc_memory_for_dlsym[0]);
 static void *AllocateFromLocalPool(uptr size_in_bytes) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36430.110094.patch
Type: text/x-patch
Size: 491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170807/0d6313f6/attachment.bin>

More information about the llvm-commits mailing list