[llvm] fix: asan support aarch64be (PR #70536)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 28 21:39:53 PDT 2023
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/70536
>From 5cd3422497a770453e4395280d1c3cf38eec61b8 Mon Sep 17 00:00:00 2001
From: hstk30-hw <hanwei62 at huawei.com>
Date: Sat, 28 Oct 2023 11:25:09 +0800
Subject: [PATCH 1/6] fix: asan support aarch64be
---
.../Instrumentation/AddressSanitizer.cpp | 3 ++-
.../AddressSanitizer/aarch64.ll | 23 +++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/Instrumentation/AddressSanitizer/aarch64.ll
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index bde5fba20f3b7a6..554c08c88bbe4ea 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/aarch64.ll b/llvm/test/Instrumentation/AddressSanitizer/aarch64.ll
new file mode 100644
index 000000000000000..2e7affa3bee2c47
--- /dev/null
+++ b/llvm/test/Instrumentation/AddressSanitizer/aarch64.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
\ No newline at end of file
>From e58134fbafc20fec312c3451e393996646cd80f0 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at gmail.com>
Date: Fri, 27 Oct 2023 21:54:57 -0700
Subject: [PATCH 2/6] Rename aarch64.ll to aarch64be.ll
---
.../AddressSanitizer/{aarch64.ll => aarch64be.ll} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename llvm/test/Instrumentation/AddressSanitizer/{aarch64.ll => aarch64be.ll} (97%)
diff --git a/llvm/test/Instrumentation/AddressSanitizer/aarch64.ll b/llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll
similarity index 97%
rename from llvm/test/Instrumentation/AddressSanitizer/aarch64.ll
rename to llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll
index 2e7affa3bee2c47..1850efaf8a927a0 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/aarch64.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/aarch64be.ll
@@ -20,4 +20,4 @@ entry:
; Check for ASAN's Offset for AArch64 BE (1 << 36 or 68719476736)
; CHECK-AARCH64BE: lshr {{.*}} 3
; CHECK-AARCH64BE-NEXT: {{68719476736}}
-; CHECK-AARCH64BE: ret
\ No newline at end of file
+; CHECK-AARCH64BE: ret
>From bfed5859cce5ffd7db5458ba9bb480edae0e8517 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 28 Oct 2023 17:00:45 -0700
Subject: [PATCH 3/6] abd format test commit
---
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 554c08c88bbe4ea..a7b0c82b9763907 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -15,6 +15,8 @@
//
//===----------------------------------------------------------------------===//
+// This comment is going to be way too long and should definitley make the code formatter scream at me,
+
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
>From a84a04443dd2578a29f4317a70db4dd8212e45bc Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 28 Oct 2023 17:08:21 -0700
Subject: [PATCH 4/6] more testing
---
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index a7b0c82b9763907..3e86bd20f398e3e 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -15,7 +15,7 @@
//
//===----------------------------------------------------------------------===//
-// This comment is going to be way too long and should definitley make the code formatter scream at me,
+// This comment is going to be way too long and should definitley make the code formatter scream at me, ghghghghfjfdjfj
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/ADT/ArrayRef.h"
>From eaeca889fe1eb0d8588e635958d1a7e166c8f5f5 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 28 Oct 2023 17:13:05 -0700
Subject: [PATCH 5/6] Another bad commit
---
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 3e86bd20f398e3e..e199722b3a93c6c 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -15,7 +15,7 @@
//
//===----------------------------------------------------------------------===//
-// This comment is going to be way too long and should definitley make the code formatter scream at me, ghghghghfjfdjfj
+// This comment is going to be way too long and should definitley make the code formatter scream at me, ghghghghfjfdjfjasfjdasdjfas
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/ADT/ArrayRef.h"
>From 8f55afec09979ceb5f565e1082bb7692668820af Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 28 Oct 2023 17:23:03 -0700
Subject: [PATCH 6/6] another test commit
---
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index e199722b3a93c6c..c492f5314988018 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -15,7 +15,7 @@
//
//===----------------------------------------------------------------------===//
-// This comment is going to be way too long and should definitley make the code formatter scream at me, ghghghghfjfdjfjasfjdasdjfas
+// This comment is going to be way too long and should definitley make the code formatter scream at me, ghghghghfjfdjfjasfjdasdjfasffjfjfhgh
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
#include "llvm/ADT/ArrayRef.h"
More information about the llvm-commits
mailing list