[llvm] e605fba - fix: asan support aarch64be (#70536)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 29 02:28:16 PDT 2023


Author: hstk30-hw
Date: 2023-10-29T02:28:11-07:00
New Revision: e605fba343d1f3cd2f538249546cfce71212ed23

URL: https://github.com/llvm/llvm-project/commit/e605fba343d1f3cd2f538249546cfce71212ed23
DIFF: https://github.com/llvm/llvm-project/commit/e605fba343d1f3cd2f538249546cfce71212ed23.diff

LOG: fix: asan support aarch64be (#70536)

fix bad `Offset` for aarch64be asan

---------

Co-authored-by: Vitaly Buka <vitalybuka at gmail.com>

Added: 
    llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll

Modified: 
    llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index e80ee1953de6b21..1277f88111d1117 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -491,7 +491,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
   bool IsMIPS32 = TargetTriple.isMIPS32();
   bool IsMIPS64 = TargetTriple.isMIPS64();
   bool IsArmOrThumb = TargetTriple.isARM() || TargetTriple.isThumb();
-  bool IsAArch64 = TargetTriple.getArch() == Triple::aarch64;
+  bool IsAArch64 = TargetTriple.getArch() == Triple::aarch64 ||
+                   TargetTriple.getArch() == Triple::aarch64_be;
   bool IsLoongArch64 = TargetTriple.isLoongArch64();
   bool IsRISCV64 = TargetTriple.getArch() == Triple::riscv64;
   bool IsWindows = TargetTriple.isOSWindows();

diff  --git a/llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll b/llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll
new file mode 100644
index 000000000000000..1850efaf8a927a0
--- /dev/null
+++ b/llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll
@@ -0,0 +1,23 @@
+; RUN: opt < %s -passes='asan-pipeline' -S -mtriple=aarch64-linux-gnu | FileCheck --check-prefix=CHECK-AARCH64LE %s
+ 
+; RUN: opt < %s -passes='asan-pipeline' -S -mtriple=aarch64_be-linux-gnu | FileCheck --check-prefix=CHECK-AARCH64BE %s
+ 
+define i32 @read_4_bytes(i32* %a) sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  ret i32 %tmp1
+}
+ 
+; CHECK-AARCH64LE: @read_4_bytes
+; CHECK-AARCH64LE-NOT: ret
+; Check for ASAN's Offset for AArch64 LE (1 << 36 or 68719476736)
+; CHECK-AARCH64LE: lshr {{.*}} 3
+; CHECK-AARCH64Le-NEXT: {{68719476736}}
+; CHECK-AARCH64LE: ret
+ 
+; CHECK-AARCH64BE: @read_4_bytes
+; CHECK-AARCH64BE-NOT: ret
+; Check for ASAN's Offset for AArch64 BE (1 << 36 or 68719476736)
+; CHECK-AARCH64BE: lshr {{.*}} 3
+; CHECK-AARCH64BE-NEXT: {{68719476736}}
+; CHECK-AARCH64BE: ret


        


More information about the llvm-commits mailing list