[PATCH] D152692: [sanitizer][msan] The LLVM part of the LoongArch memory sanitizer implementation
Limin Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 12 03:00:14 PDT 2023
Ami-zhang created this revision.
Ami-zhang added reviewers: vitalybuka, SixWeining, xen0n, xry111, MaskRay, tangyouling.
Herald added subscribers: Enna1, pengfei, hiraditya.
Herald added a project: All.
Ami-zhang requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152692
Files:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll
Index: llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll
===================================================================
--- /dev/null
+++ 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)
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -438,6 +438,14 @@
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
@@ -495,6 +503,11 @@
&Linux_AArch64_MemoryMapParams,
};
+static const PlatformMemoryMapParams Linux_LoongArch_MemoryMapParams = {
+ nullptr,
+ &Linux_LoongArch64_MemoryMapParams,
+};
+
static const PlatformMemoryMapParams FreeBSD_ARM_MemoryMapParams = {
nullptr,
&FreeBSD_AArch64_MemoryMapParams,
@@ -1016,6 +1029,9 @@
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");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152692.530443.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230612/72d2029a/attachment.bin>
More information about the llvm-commits
mailing list