[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
Wed Jun 28 20:42:05 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3749292e508b: [sanitizer][msan] The LLVM part of the LoongArch memory sanitizer implementation (authored by Ami-zhang).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152692/new/

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
@@ -439,6 +439,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
@@ -496,6 +504,11 @@
     &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 @@
       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.535615.patch
Type: text/x-patch
Size: 1965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/c72b9be3/attachment.bin>


More information about the llvm-commits mailing list