[llvm] 3749292 - [sanitizer][msan] The LLVM part of the LoongArch memory sanitizer implementation
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 20:41:48 PDT 2023
Author: zhanglimin
Date: 2023-06-29T11:41:27+08:00
New Revision: 3749292e508b92f6a355e6a6e5f3456bbdd43c8e
URL: https://github.com/llvm/llvm-project/commit/3749292e508b92f6a355e6a6e5f3456bbdd43c8e
DIFF: https://github.com/llvm/llvm-project/commit/3749292e508b92f6a355e6a6e5f3456bbdd43c8e.diff
LOG: [sanitizer][msan] The LLVM part of the LoongArch memory sanitizer implementation
This patch enabled msan in LLVM and fixed all failing tests in
check-msan.
It does not add VarArgHelper implementation on LoongArch, which
will be done separately later. And it adds a test for VarArgNoOpHelper,
which is based on the X86 one.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D152692
Added:
llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll
Modified:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 204b2620dda45a..83d90049abc39e 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -439,6 +439,14 @@ static const MemoryMapParams Linux_AArch64_MemoryMapParams = {
0x0200000000000, // OriginBase
};
+// loongarch64 Linux
+static const MemoryMapParams Linux_LoongArch64_MemoryMapParams = {
+ 0, // AndMask (not used)
+ 0x500000000000, // XorMask
+ 0, // ShadowBase (not used)
+ 0x100000000000, // OriginBase
+};
+
// aarch64 FreeBSD
static const MemoryMapParams FreeBSD_AArch64_MemoryMapParams = {
0x1800000000000, // AndMask
@@ -496,6 +504,11 @@ static const PlatformMemoryMapParams Linux_ARM_MemoryMapParams = {
&Linux_AArch64_MemoryMapParams,
};
+static const PlatformMemoryMapParams Linux_LoongArch_MemoryMapParams = {
+ nullptr,
+ &Linux_LoongArch64_MemoryMapParams,
+};
+
static const PlatformMemoryMapParams FreeBSD_ARM_MemoryMapParams = {
nullptr,
&FreeBSD_AArch64_MemoryMapParams,
@@ -1017,6 +1030,9 @@ void MemorySanitizer::initializeModule(Module &M) {
case Triple::aarch64_be:
MapParams = Linux_ARM_MemoryMapParams.bits64;
break;
+ case Triple::loongarch64:
+ MapParams = Linux_LoongArch_MemoryMapParams.bits64;
+ break;
default:
report_fatal_error("unsupported architecture");
}
diff --git a/llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll b/llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll
new file mode 100644
index 00000000000000..dcbe2a24224885
--- /dev/null
+++ b/llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1
+; Test that code using va_start can be compiled on LoongArch.
+
+target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
+target triple = "loongarch64-unknown-linux-gnu"
+
+define void @VaStart(ptr %s, ...) {
+entry:
+ %vl = alloca ptr, align 4
+ call void @llvm.va_start(ptr %vl)
+ ret void
+}
+
+declare void @llvm.va_start(ptr)
More information about the llvm-commits
mailing list