BumpPtrAllocator already has MSan hooks to teach the sanitizer about what memory is valid.
This patch adds the equivalent for ASan. New slabs are initially poisoned then each individual allocation is unopposed.
BumpPtrAllocator has an empty Deallocate method, however, we can use that here to ensure that once a region has been Deallocated, we poison it and don't continue to use it. A similar change should probably be made for MSan.
Unfortunately this patch can't yet be committed due to a bug found in clang with this applied (https://llvm.org/bugs/show_bug.cgi?id=23516). I'm putting this up on Phab in case anyone else wants to try it out. It may also be better to move most of the #ifdefs to Compiler.h where __msan_allocated_memory is currently defined, so i expect to change this patch in future.
I don't like so many ifdefs.
Maybe like this?
#if LLVM_ADDRESS_SANITIZER_BUILD
include ...
#else
#endif