[llvm] 280d163 - [dfsan] Support Linux loongarch64
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 3 01:07:20 PDT 2023
Author: zhanglimin
Date: 2023-07-03T16:05:02+08:00
New Revision: 280d163887eade88bb9c2c300337b0bc414d6301
URL: https://github.com/llvm/llvm-project/commit/280d163887eade88bb9c2c300337b0bc414d6301
DIFF: https://github.com/llvm/llvm-project/commit/280d163887eade88bb9c2c300337b0bc414d6301.diff
LOG: [dfsan] Support Linux loongarch64
Make minor changes to enable DFSAN and its tests on
loongarch64. And port Linux loongarch64 memory mappings
from msan.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D140690
Added:
Modified:
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
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 33a431a54da67e..1ba222bf83b103 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -795,7 +795,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
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)
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 3b04e9de5e7578..dfa0f634b4c6b7 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -30,7 +30,7 @@ set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
${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")
diff --git a/compiler-rt/test/dfsan/lit.cfg.py b/compiler-rt/test/dfsan/lit.cfg.py
index 286c0c7aab1daf..e947c51f99a5ba 100644
--- a/compiler-rt/test/dfsan/lit.cfg.py
+++ b/compiler-rt/test/dfsan/lit.cfg.py
@@ -25,5 +25,5 @@ def build_invocation(compile_flags):
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
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 634e4508f91070..8caee5bed8ed08 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -305,6 +305,14 @@ const MemoryMapParams Linux_X86_64_MemoryMapParams = {
};
// 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 @@ bool DataFlowSanitizer::initializeModule(Module &M) {
case Triple::x86_64:
MapParams = &Linux_X86_64_MemoryMapParams;
break;
+ case Triple::loongarch64:
+ MapParams = &Linux_LoongArch64_MemoryMapParams;
+ break;
default:
report_fatal_error("unsupported architecture");
}
More information about the llvm-commits
mailing list