[PATCH] D140690: [dfsan] Support Linux loongarch64

Limin Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 20:10:51 PDT 2023


Ami-zhang updated this revision to Diff 536091.
Ami-zhang retitled this revision from "[compiler-rt][dfsan] Enable loongarch64 and add test support" to "[dfsan] Support Linux loongarch64".
Ami-zhang edited the summary of this revision.
Ami-zhang added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140690

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/test/dfsan/lit.cfg.py
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -305,6 +305,14 @@
 };
 // NOLINTEND(readability-identifier-naming)
 
+// loongarch64 Linux
+const MemoryMapParams Linux_LoongArch64_MemoryMapParams = {
+    0,              // AndMask (not used)
+    0x500000000000, // XorMask
+    0,              // ShadowBase (not used)
+    0x100000000000, // OriginBase
+};
+
 namespace {
 
 class DFSanABIList {
@@ -1128,6 +1136,9 @@
   case Triple::x86_64:
     MapParams = &Linux_X86_64_MemoryMapParams;
     break;
+  case Triple::loongarch64:
+    MapParams = &Linux_LoongArch64_MemoryMapParams;
+    break;
   default:
     report_fatal_error("unsupported architecture");
   }
Index: compiler-rt/test/dfsan/lit.cfg.py
===================================================================
--- compiler-rt/test/dfsan/lit.cfg.py
+++ compiler-rt/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@
 config.suffixes = [".c", ".cpp"]
 
 # DataFlowSanitizer tests are currently supported on Linux only.
-if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64"]):
+if not (config.host_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]):
     config.unsupported = True
Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===================================================================
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -30,7 +30,7 @@
     ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
     ${LOONGARCH64})
 set(ALL_ASAN_ABI_SUPPORTED_ARCH ${X86_64} ${ARM64})
-set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
+set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${LOONGARCH64})
 
 if(ANDROID)
   set(OS_NAME "Android")
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -795,7 +795,7 @@
   Res |= SanitizerKind::Memory;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsLoongArch64)
     Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
       IsRISCV64 || IsSystemZ || IsHexagon || IsLoongArch64)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140690.536091.patch
Type: text/x-patch
Size: 2587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230630/c3efa4ab/attachment.bin>


More information about the cfe-commits mailing list