[llvm] r201067 - [asan] support for FreeBSD, LLVM part. patch by Viktor Kutuzov
Kostya Serebryany
kcc at google.com
Sun Feb 9 23:37:04 PST 2014
Author: kcc
Date: Mon Feb 10 01:37:04 2014
New Revision: 201067
URL: http://llvm.org/viewvc/llvm-project?rev=201067&view=rev
Log:
[asan] support for FreeBSD, LLVM part. patch by Viktor Kutuzov
Added:
llvm/trunk/test/Instrumentation/AddressSanitizer/freebsd.ll
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=201067&r1=201066&r2=201067&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Mon Feb 10 01:37:04 2014
@@ -60,6 +60,8 @@ static const uint64_t kDefaultShadowOffs
static const uint64_t kDefaultShort64bitShadowOffset = 0x7FFF8000; // < 2G.
static const uint64_t kPPC64_ShadowOffset64 = 1ULL << 41;
static const uint64_t kMIPS32_ShadowOffset32 = 0x0aaa8000;
+static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
+static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
static const size_t kMinStackMallocSize = 1 << 6; // 64B
static const size_t kMaxStackMallocSize = 1 << 16; // 64K
@@ -240,6 +242,7 @@ static ShadowMapping getShadowMapping(co
llvm::Triple TargetTriple(M.getTargetTriple());
bool IsAndroid = TargetTriple.getEnvironment() == llvm::Triple::Android;
bool IsMacOSX = TargetTriple.getOS() == llvm::Triple::MacOSX;
+ bool IsFreeBSD = TargetTriple.getOS() == llvm::Triple::FreeBSD;
bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 ||
TargetTriple.getArch() == llvm::Triple::ppc64le;
bool IsX86_64 = TargetTriple.getArch() == llvm::Triple::x86_64;
@@ -255,11 +258,13 @@ static ShadowMapping getShadowMapping(co
Mapping.Offset = IsAndroid ? 0 :
(LongSize == 32 ?
- (IsMIPS32 ? kMIPS32_ShadowOffset32 : kDefaultShadowOffset32) :
+ (IsMIPS32 ? kMIPS32_ShadowOffset32 :
+ (IsFreeBSD ? kFreeBSD_ShadowOffset32 : kDefaultShadowOffset32)) :
IsPPC64 ? kPPC64_ShadowOffset64 : kDefaultShadowOffset64);
if (!IsAndroid && ClShort64BitOffset && IsX86_64 && !IsMacOSX) {
assert(LongSize == 64);
- Mapping.Offset = kDefaultShort64bitShadowOffset;
+ Mapping.Offset = (IsFreeBSD ?
+ kFreeBSD_ShadowOffset64 : kDefaultShort64bitShadowOffset);
}
if (!IsAndroid && ClMappingOffsetLog >= 0) {
// Zero offset log is the special case.
Added: llvm/trunk/test/Instrumentation/AddressSanitizer/freebsd.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/freebsd.ll?rev=201067&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/freebsd.ll (added)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/freebsd.ll Mon Feb 10 01:37:04 2014
@@ -0,0 +1,29 @@
+; RUN: opt < %s -asan -S \
+; RUN: -mtriple=i386-unknown-freebsd \
+; RUN: -default-data-layout="e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" | \
+; RUN: FileCheck --check-prefix=CHECK-32 %s
+
+; RUN: opt < %s -asan -S \
+; RUN: -mtriple=x86_64-unknown-freebsd \
+; RUN: -default-data-layout="e-m:e-i64:64-f80:128-n8:16:32:64-S128" | \
+; RUN: FileCheck --check-prefix=CHECK-64 %s
+
+define i32 @read_4_bytes(i32* %a) sanitize_address {
+entry:
+ %tmp1 = load i32* %a, align 4
+ ret i32 %tmp1
+}
+
+; CHECK-32: @read_4_bytes
+; CHECK-32-NOT: ret
+; Check for ASAN's Offset for 32-bit (2^30 or 0x40000000)
+; CHECK-32: lshr {{.*}} 3
+; CHECK-32-NEXT: {{1073741824}}
+; CHECK-32: ret
+
+; CHECK-64: @read_4_bytes
+; CHECK-64-NOT: ret
+; Check for ASAN's Offset for 64-bit (2^46 or 0x400000000000)
+; CHECK-64: lshr {{.*}} 3
+; CHECK-64-NEXT: {{70368744177664}}
+; CHECK-64: ret
More information about the llvm-commits
mailing list