diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -108,6 +108,7 @@ 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 @@ 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 --- 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 @@ ; 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)