Skip to content

Conversation

@anoopkg6
Copy link
Contributor

Fix build failure due to newly introduced PtrShift(), seems to scale to the size of shadow memory, which is 8 bytes for each byte in application. These changes are applied to sizes shifted left by 3. I am not sure if it affects anything related to ShadowAddr, AppAddr, and AppMask.
Choosing kPtrShift to be 3 like other architectures. Tests pass.
@gbMattN

@llvmbot llvmbot added compiler-rt clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' compiler-rt:sanitizer labels Nov 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (anoopkg6)

Changes

Fix build failure due to newly introduced PtrShift(), seems to scale to the size of shadow memory, which is 8 bytes for each byte in application. These changes are applied to sizes shifted left by 3. I am not sure if it affects anything related to ShadowAddr, AppAddr, and AppMask.
Choosing kPtrShift to be 3 like other architectures. Tests pass.
@gbMattN


Full diff: https://github.com/llvm/llvm-project/pull/169746.diff

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Linux.cpp (+1-1)
  • (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1)
  • (modified) compiler-rt/lib/tysan/tysan_platform.h (+7)
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 2c741a38fce1a..cdbf21fb90263 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -922,7 +922,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ ||
       IsLoongArch64 || IsRISCV64)
     Res |= SanitizerKind::Thread;
-  if (IsX86_64 || IsAArch64)
+  if (IsX86_64 || IsAArch64 || IsSystemZ)
     Res |= SanitizerKind::Type;
   if (IsX86_64 || IsSystemZ || IsPowerPC64)
     Res |= SanitizerKind::KernelMemory;
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index c10367715396e..f2317de8916e9 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -89,7 +89,7 @@ else()
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}
       ${LOONGARCH64} ${RISCV64})
 endif()
-set(ALL_TYSAN_SUPPORTED_ARCH ${X86_64} ${ARM64})
+set(ALL_TYSAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${S390X})
 set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
     ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
     ${LOONGARCH64})
diff --git a/compiler-rt/lib/tysan/tysan_platform.h b/compiler-rt/lib/tysan/tysan_platform.h
index 19f77f0cace6b..96049c8d1c9a2 100644
--- a/compiler-rt/lib/tysan/tysan_platform.h
+++ b/compiler-rt/lib/tysan/tysan_platform.h
@@ -45,6 +45,13 @@ struct Mapping48 {
   static const uptr kPtrShift = 3;
 };
 #define TYSAN_RUNTIME_VMA 1
+#elif defined(__s390x__)
+struct Mapping {
+  static const uptr kShadowAddr = 0x080000000000ULL;
+  static const uptr kAppAddr = 0x460000000000ULL;
+  static const uptr kAppMemMsk = ~0xC00000000000ULL;
+  static const uptr kPtrShift = 3;
+};
 #else
 #error "TySan not supported for this platform!"
 #endif

@thurstond
Copy link
Contributor

Since this patch isn't only a fix-forward, but also re-applying a patch, please include in the commit message which patch is being re-applied (#162396) and what that patch does. Likewise, the title should also allude to its effect of adding Type Sanitizer support for SystemZ.

@thurstond thurstond requested a review from gbMattN November 26, 2025 23:44
Copy link
Contributor

@gbMattN gbMattN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! Can be merged when all tests pass

anoopkg6 pushed a commit to anoopkg6/llvm-project that referenced this pull request Nov 27, 2025
@anoopkg6
Copy link
Contributor Author

Closing this patch as re-submitting new patch #169850 for TySan support for SystemZ, which includes original reverted patch #162396 along with this patch.

@anoopkg6 anoopkg6 closed this Nov 27, 2025
uweigand pushed a commit that referenced this pull request Dec 1, 2025
…96 (#169850)

This is a re-submission of original reverted patch [(#162396)
](https://github.com/llvm/llvm-project/pull/162396url)for adding TySan
support for systemzZ along with build failure patch
[#169746](#169746).

See conversations in #169746.

Co-authored-by: anoopkg6 <[email protected]>
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Dec 1, 2025
…nal pr#162396 (#169850)

This is a re-submission of original reverted patch [(#162396)
](https://github.com/llvm/llvm-project/pull/162396url)for adding TySan
support for systemzZ along with build failure patch
[#169746](llvm/llvm-project#169746).

See conversations in #169746.

Co-authored-by: anoopkg6 <[email protected]>
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Dec 3, 2025
…96 (llvm#169850)

This is a re-submission of original reverted patch [(llvm#162396)
](https://github.com/llvm/llvm-project/pull/162396url)for adding TySan
support for systemzZ along with build failure patch
[llvm#169746](llvm#169746).

See conversations in llvm#169746.

Co-authored-by: anoopkg6 <[email protected]>
kcloudy0717 pushed a commit to kcloudy0717/llvm-project that referenced this pull request Dec 4, 2025
…96 (llvm#169850)

This is a re-submission of original reverted patch [(llvm#162396)
](https://github.com/llvm/llvm-project/pull/162396url)for adding TySan
support for systemzZ along with build failure patch
[llvm#169746](llvm#169746).

See conversations in llvm#169746.

Co-authored-by: anoopkg6 <[email protected]>
honeygoyal pushed a commit to honeygoyal/llvm-project that referenced this pull request Dec 9, 2025
…96 (llvm#169850)

This is a re-submission of original reverted patch [(llvm#162396)
](https://github.com/llvm/llvm-project/pull/162396url)for adding TySan
support for systemzZ along with build failure patch
[llvm#169746](llvm#169746).

See conversations in llvm#169746.

Co-authored-by: anoopkg6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' compiler-rt:sanitizer compiler-rt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants