[llvm] e13bd26 - Add the FreeBSD AArch64 shadow offset to llvm
Ed Maste via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 06:58:59 PDT 2022
Author: Andrew Turner
Date: 2022-07-19T09:58:07-04:00
New Revision: e13bd2644edf8f7d8df9d045f1d14f62ddfe05db
URL: https://github.com/llvm/llvm-project/commit/e13bd2644edf8f7d8df9d045f1d14f62ddfe05db
DIFF: https://github.com/llvm/llvm-project/commit/e13bd2644edf8f7d8df9d045f1d14f62ddfe05db.diff
LOG: Add the FreeBSD AArch64 shadow offset to llvm
AArch64 has a larger address space than 64 but x86. Use the larger
shadow offset on FreeBSD AArch64.
Reviewed by: vitalybuka
Differential Revision: https://reviews.llvm.org/D125873
Added:
Modified:
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/freebsd.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 4fed4bd18fb18..cf2754b1dd602 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -108,6 +108,7 @@ static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
static const uint64_t kRISCV64_ShadowOffset64 = 0xd55550000;
static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
+static const uint64_t kFreeBSDAArch64_ShadowOffset64 = 1ULL << 47;
static const uint64_t kFreeBSDKasan_ShadowOffset64 = 0xdffff7c000000000;
static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30;
static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46;
@@ -523,6 +524,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
Mapping.Offset = kPPC64_ShadowOffset64;
else if (IsSystemZ)
Mapping.Offset = kSystemZ_ShadowOffset64;
+ else if (IsFreeBSD && IsAArch64)
+ Mapping.Offset = kFreeBSDAArch64_ShadowOffset64;
else if (IsFreeBSD && !IsMIPS64) {
if (IsKasan)
Mapping.Offset = kFreeBSDKasan_ShadowOffset64;
diff --git a/llvm/test/Instrumentation/AddressSanitizer/freebsd.ll b/llvm/test/Instrumentation/AddressSanitizer/freebsd.ll
index cdb5406a31474..13baa4d0dd425 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/freebsd.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/freebsd.ll
@@ -8,6 +8,11 @@
; RUN: -data-layout="e-m:e-i64:64-f80:128-n8:16:32:64-S128" | \
; RUN: FileCheck --check-prefix=CHECK-64 %s
+; RUN: opt < %s -passes='asan-pipeline' -S \
+; RUN: -mtriple=aarch64-unknown-freebsd \
+; RUN: -data-layout="e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | \
+; RUN: FileCheck --check-prefix=CHECK-AARCH64 %s
+
; RUN: opt < %s -passes='asan-pipeline' -S \
; RUN: -mtriple=mips64-unknown-freebsd \
; RUN: -data-layout="E-m:e-i64:64-n32:64-S128" | \
@@ -33,6 +38,13 @@ entry:
; CHECK-64-NEXT: {{70368744177664}}
; CHECK-64: ret
+; CHECK-AARCH64: @read_4_bytes
+; CHECK-AARCH64-NOT: ret
+; Check for ASAN's Offset for 64-bit (2^47 or 0x800000000000)
+; CHECK-AARCH64: lshr {{.*}} 3
+; CHECK-AARCH64-NEXT: {{140737488355328}}
+; CHECK-AARCH64: ret
+
; CHECK-MIPS64: @read_4_bytes
; CHECK-MIPS64-NOT: ret
; Check for ASAN's Offset for 64-bit (2^37 or 0x2000000000)
More information about the llvm-commits
mailing list