summaryrefslogtreecommitdiff
path: root/lib/Support/Allocator.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-01-31 09:58:59 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-01-31 09:58:59 +0000
commitea2d8780e9c78628fe5e3312ca4c17c054156c83 (patch)
tree72f8d01f1abf5b7c424bef6a733d003cb8764068 /lib/Support/Allocator.cpp
parente22df330a344ddbd536e6bcbc542290953ab4a9d (diff)
downloadllvm-ea2d8780e9c78628fe5e3312ca4c17c054156c83.tar.gz
llvm-ea2d8780e9c78628fe5e3312ca4c17c054156c83.tar.bz2
llvm-ea2d8780e9c78628fe5e3312ca4c17c054156c83.tar.xz
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/Support/Allocator.cpp')
-rw-r--r--lib/Support/Allocator.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp
index 28f4e64ac7..b4fdc1e1bc 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;
}