[compiler-rt] r310330 - [asan] Restore dead-code-elimination optimization for Fuchsia

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 18:02:00 PDT 2017


Author: vitalybuka
Date: Mon Aug  7 18:01:59 2017
New Revision: 310330

URL: http://llvm.org/viewvc/llvm-project?rev=310330&view=rev
Log:
[asan] Restore dead-code-elimination optimization for Fuchsia

Summary:
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.

Submitted on behalf of Roland McGrath.

Reviewers: vitalybuka, alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits, kubamracek

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D36430

Modified:
    compiler-rt/trunk/lib/asan/asan_malloc_linux.cc

Modified: compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_linux.cc?rev=310330&r1=310329&r2=310330&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_malloc_linux.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_malloc_linux.cc Mon Aug  7 18:01:59 2017
@@ -32,7 +32,7 @@ static uptr alloc_memory_for_dlsym[kDlsy
 
 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) {




More information about the llvm-commits mailing list