[PATCH] D36190: [asan] Allocator support for Fuchsia
Roland McGrath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 7 14:22:07 PDT 2017
mcgrathr added inline comments.
================
Comment at: lib/asan/asan_malloc_linux.cc:35
uptr off = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
- return off < sizeof(alloc_memory_for_dlsym);
+ return off < allocated_for_dlsym;
}
----------------
vitalybuka wrote:
> Why sizeof is gone here?
Previously it was sizeof(alloc_memory_for_dlsym), the static size of the static buffer.
I changed it to allocated_for_dlsym, which is the dynamic count of how much of the static buffer has been used.
The reason for the change is that in the SANITIZER_FUCHSIA case, the compiler can see statically that nothing ever sets allocated_for_dlsym and so it will always be zero and hence this comparison is always false and it can optimize away all the related dead code entirely.
In theory the change is harmless because the offset of any allocated block will be less than the current count.
However, I failed to notice that the count in allocated_for_dlsym is of sizeof(uptr) units while the comparison is being made against a byte count. Hence I introduced https://bugs.llvm.org/show_bug.cgi?id=34085 with the change. I'll do a follow-up change that gets the comparison arithmetic right, so that bug won't happen but Fuchsia will get back the dead code elimination I was going for with the change.
Repository:
rL LLVM
https://reviews.llvm.org/D36190
More information about the llvm-commits
mailing list