summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-02-04 07:03:24 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-02-04 07:03:24 +0000
commit9c02a276049cbd1d1511a88ebc7a22bb33658237 (patch)
treefe1428d48ffb3a0f8dc06216ea2dfe493e7369a7 /lib
parentf839eed5ea2bfd395256d60e15d1e31dbad6ca8b (diff)
downloadllvm-9c02a276049cbd1d1511a88ebc7a22bb33658237.tar.gz
llvm-9c02a276049cbd1d1511a88ebc7a22bb33658237.tar.bz2
llvm-9c02a276049cbd1d1511a88ebc7a22bb33658237.tar.xz
More MSan/ASan annotations.
This change lets us bootstrap LLVM/Clang under ASan and MSan. It contains fixes for 2 issues: - X86JIT reads return address from stack, which MSan does not know is initialized. - bugpoint tests run binaries with RLIMIT_AS. This does not work with certain Sanitizers. We are no longer including config.h in Compiler.h with this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/Allocator.cpp4
-rw-r--r--lib/Support/Unix/Program.inc5
-rw-r--r--lib/Target/X86/X86JITInfo.cpp3
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp
index b4fdc1e1bc..e269cf997a 100644
--- a/lib/Support/Allocator.cpp
+++ b/lib/Support/Allocator.cpp
@@ -104,8 +104,8 @@ void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) {
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.
+ // Without this, MemorySanitizer messages for values originated from here
+ // will point to the allocation of the entire slab.
__msan_allocated_memory(Ptr, Size);
return Ptr;
}
diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc
index c384316e20..117151c91d 100644
--- a/lib/Support/Unix/Program.inc
+++ b/lib/Support/Unix/Program.inc
@@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//
#include "Unix.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/FileSystem.h"
#include <llvm/Config/config.h>
#if HAVE_SYS_STAT_H
@@ -164,12 +165,16 @@ static void SetMemoryLimits (unsigned size)
setrlimit (RLIMIT_RSS, &r);
#endif
#ifdef RLIMIT_AS // e.g. NetBSD doesn't have it.
+ // Don't set virtual memory limit if built with any Sanitizer. They need 80Tb
+ // of virtual memory for shadow memory mapping.
+#if !LLVM_MEMORY_SANITIZER_BUILD && !LLVM_ADDRESS_SANITIZER_BUILD
// Virtual memory.
getrlimit (RLIMIT_AS, &r);
r.rlim_cur = limit;
setrlimit (RLIMIT_AS, &r);
#endif
#endif
+#endif
}
bool
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp
index cca391f647..0a4accee99 100644
--- a/lib/Target/X86/X86JITInfo.cpp
+++ b/lib/Target/X86/X86JITInfo.cpp
@@ -351,6 +351,9 @@ static
void LLVM_ATTRIBUTE_USED
X86CompilationCallback2(intptr_t *StackPtr, intptr_t RetAddr) {
intptr_t *RetAddrLoc = &StackPtr[1];
+ // We are reading raw stack data here. Tell MemorySanitizer that it is
+ // sufficiently initialized.
+ __msan_unpoison(RetAddrLoc, sizeof(*RetAddrLoc));
assert(*RetAddrLoc == RetAddr &&
"Could not find return address on the stack!");