diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-01-31 09:58:59 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-01-31 09:58:59 +0000 |
commit | ea2d8780e9c78628fe5e3312ca4c17c054156c83 (patch) | |
tree | 72f8d01f1abf5b7c424bef6a733d003cb8764068 /lib | |
parent | e22df330a344ddbd536e6bcbc542290953ab4a9d (diff) | |
download | external_llvm-ea2d8780e9c78628fe5e3312ca4c17c054156c83.zip external_llvm-ea2d8780e9c78628fe5e3312ca4c17c054156c83.tar.gz external_llvm-ea2d8780e9c78628fe5e3312ca4c17c054156c83.tar.bz2 |
Annotate BumpPtrAllocator for MemorySanitizer.
This change adds MemorySanitizer annotations to BumpPtrAllocator to
improve report quality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/Allocator.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 28f4e64..b4fdc1e 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Memory.h" #include "llvm/Support/Recycler.h" @@ -102,6 +103,10 @@ void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { // Check if we can hold it. if (Ptr + Size <= End) { CurPtr = Ptr + Size; + // Update the allocation point of this memory block in MemorySanitizer. + // Without this, MemorySanitizer reports for values originating from it will + // point to the allocation point of the entire slab. + __msan_allocated_memory(Ptr, Size); return Ptr; } @@ -117,6 +122,7 @@ void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { Ptr = AlignPtr((char*)(NewSlab + 1), Alignment); assert((uintptr_t)Ptr + Size <= (uintptr_t)NewSlab + NewSlab->Size); + __msan_allocated_memory(Ptr, Size); return Ptr; } @@ -125,6 +131,7 @@ void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { Ptr = AlignPtr(CurPtr, Alignment); CurPtr = Ptr + Size; assert(CurPtr <= End && "Unable to allocate memory!"); + __msan_allocated_memory(Ptr, Size); return Ptr; } |