[clang] [TSAN] add support for riscv64 (PR #68735)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 10 11:48:15 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 08545e85167a105b8147d76a48a2fa1eac0f9e9a 512ba7677b5b6656fab25f5c2b31a1ef203d9756 -- clang/lib/Driver/ToolChains/Linux.cpp compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp compiler-rt/lib/tsan/rtl/tsan_platform.h compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp compiler-rt/lib/tsan/rtl/tsan_rtl.h compiler-rt/test/tsan/map32bit.cpp compiler-rt/test/tsan/mmap_large.cpp compiler-rt/test/tsan/test.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index bb10b607278f..80f86ca98ed9 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -82,7 +82,7 @@ struct ucontext_t {
#elif SANITIZER_LOONGARCH64
#define PTHREAD_ABI_BASE "GLIBC_2.36"
#elif SANITIZER_RISCV64
-#define PTHREAD_ABI_BASE "GLIBC_2.27"
+# define PTHREAD_ABI_BASE "GLIBC_2.27"
#endif
extern "C" int pthread_attr_init(void *attr);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 43822020c0b4..cfbb57d1d8d8 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -394,22 +394,22 @@ Heap starts after program region whose position depends on pie or non-pie.
Disable tracking them since their locations are not fixed.
*/
struct MappingRiscv64_39 {
- static const uptr kLoAppMemBeg = 0x0000001000ull;
- static const uptr kLoAppMemEnd = 0x0200000000ull;
- static const uptr kShadowBeg = 0x1000000000ull;
- static const uptr kShadowEnd = 0x2000000000ull;
+ static const uptr kLoAppMemBeg = 0x0000001000ull;
+ static const uptr kLoAppMemEnd = 0x0200000000ull;
+ static const uptr kShadowBeg = 0x1000000000ull;
+ static const uptr kShadowEnd = 0x2000000000ull;
static const uptr kMetaShadowBeg = 0x2000000000ull;
static const uptr kMetaShadowEnd = 0x2400000000ull;
- static const uptr kMidAppMemBeg = 0x2aaaaaa000ull;
- static const uptr kMidAppMemEnd = 0x2c00000000ull;
- static const uptr kHeapMemBeg = 0x2c00000000ull;
- static const uptr kHeapMemEnd = 0x2c00000000ull;
- static const uptr kHiAppMemBeg = 0x3c00000000ull;
- static const uptr kHiAppMemEnd = 0x3fffffffffull;
- static const uptr kShadowMsk = 0x3800000000ull;
- static const uptr kShadowXor = 0x0800000000ull;
- static const uptr kShadowAdd = 0x0000000000ull;
- static const uptr kVdsoBeg = 0x4000000000ull;
+ static const uptr kMidAppMemBeg = 0x2aaaaaa000ull;
+ static const uptr kMidAppMemEnd = 0x2c00000000ull;
+ static const uptr kHeapMemBeg = 0x2c00000000ull;
+ static const uptr kHeapMemEnd = 0x2c00000000ull;
+ static const uptr kHiAppMemBeg = 0x3c00000000ull;
+ static const uptr kHiAppMemEnd = 0x3fffffffffull;
+ static const uptr kShadowMsk = 0x3800000000ull;
+ static const uptr kShadowXor = 0x0800000000ull;
+ static const uptr kShadowAdd = 0x0000000000ull;
+ static const uptr kVdsoBeg = 0x4000000000ull;
};
/*
@@ -424,22 +424,22 @@ C/C++ on linux/riscv64 (48-bit VMA)
7a00 0000 0000 - 7fff ffff ffff: libraries and main thread stack ( 5 TB)
*/
struct MappingRiscv64_48 {
- static const uptr kLoAppMemBeg = 0x000000001000ull;
- static const uptr kLoAppMemEnd = 0x050000000000ull;
- static const uptr kShadowBeg = 0x200000000000ull;
- static const uptr kShadowEnd = 0x400000000000ull;
+ static const uptr kLoAppMemBeg = 0x000000001000ull;
+ static const uptr kLoAppMemEnd = 0x050000000000ull;
+ static const uptr kShadowBeg = 0x200000000000ull;
+ static const uptr kShadowEnd = 0x400000000000ull;
static const uptr kMetaShadowBeg = 0x400000000000ull;
static const uptr kMetaShadowEnd = 0x480000000000ull;
- static const uptr kMidAppMemBeg = 0x555555555000ull;
- static const uptr kMidAppMemEnd = 0x5a0000000000ull;
- static const uptr kHeapMemBeg = 0x5a0000000000ull;
- static const uptr kHeapMemEnd = 0x5a0000000000ull;
- static const uptr kHiAppMemBeg = 0x7a0000000000ull;
- static const uptr kHiAppMemEnd = 0x7fffffffffffull;
- static const uptr kShadowMsk = 0x700000000000ull;
- static const uptr kShadowXor = 0x100000000000ull;
- static const uptr kShadowAdd = 0x000000000000ull;
- static const uptr kVdsoBeg = 0x800000000000ull;
+ static const uptr kMidAppMemBeg = 0x555555555000ull;
+ static const uptr kMidAppMemEnd = 0x5a0000000000ull;
+ static const uptr kHeapMemBeg = 0x5a0000000000ull;
+ static const uptr kHeapMemEnd = 0x5a0000000000ull;
+ static const uptr kHiAppMemBeg = 0x7a0000000000ull;
+ static const uptr kHiAppMemEnd = 0x7fffffffffffull;
+ static const uptr kShadowMsk = 0x700000000000ull;
+ static const uptr kShadowXor = 0x100000000000ull;
+ static const uptr kShadowAdd = 0x000000000000ull;
+ static const uptr kVdsoBeg = 0x800000000000ull;
};
/*
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
index 709a4322ed7d..369509ed0a60 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -267,17 +267,17 @@ void InitializePlatformEarly() {
Die();
}
# endif
-#elif SANITIZER_RISCV64
+# elif SANITIZER_RISCV64
// the bottom half of vma is allocated for userspace
vmaSize = vmaSize + 1;
-# if !SANITIZER_GO
+# if !SANITIZER_GO
if (vmaSize != 39 && vmaSize != 48) {
Printf("FATAL: ThreadSanitizer: unsupported VMA range\n");
Printf("FATAL: Found %zd - Supported 39 and 48\n", vmaSize);
Die();
}
-# endif
-#endif
+# endif
+# endif
}
void InitializePlatform() {
@@ -409,15 +409,15 @@ static uptr UnmangleLongJmpSp(uptr mangled_sp) {
return mangled_sp ^ xor_key;
#elif defined(__mips__)
return mangled_sp;
-#elif SANITIZER_RISCV64
+# elif SANITIZER_RISCV64
return mangled_sp;
-#elif defined(__s390x__)
+# elif defined(__s390x__)
// tcbhead_t.stack_guard
uptr xor_key = ((uptr *)__builtin_thread_pointer())[5];
return mangled_sp ^ xor_key;
-#else
- #error "Unknown platform"
-#endif
+# else
+# error "Unknown platform"
+# endif
}
#if SANITIZER_NETBSD
@@ -441,13 +441,13 @@ static uptr UnmangleLongJmpSp(uptr mangled_sp) {
# define LONG_JMP_SP_ENV_SLOT 1
# elif defined(__mips64)
# define LONG_JMP_SP_ENV_SLOT 1
-# elif SANITIZER_RISCV64
-# define LONG_JMP_SP_ENV_SLOT 13
-# elif defined(__s390x__)
-# define LONG_JMP_SP_ENV_SLOT 9
-# else
-# define LONG_JMP_SP_ENV_SLOT 6
-# endif
+# elif SANITIZER_RISCV64
+# define LONG_JMP_SP_ENV_SLOT 13
+# elif defined(__s390x__)
+# define LONG_JMP_SP_ENV_SLOT 9
+# else
+# define LONG_JMP_SP_ENV_SLOT 6
+# endif
#endif
uptr ExtractLongJmpSp(uptr *env) {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index e074e6fede5d..de4ea0bb5f48 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -56,8 +56,8 @@ namespace __tsan {
#if !SANITIZER_GO
struct MapUnmapCallback;
-#if defined(__mips64) || defined(__aarch64__) || defined(__loongarch__) || \
- defined(__powerpc__) || SANITIZER_RISCV64
+# if defined(__mips64) || defined(__aarch64__) || defined(__loongarch__) || \
+ defined(__powerpc__) || SANITIZER_RISCV64
struct AP32 {
static const uptr kSpaceBeg = 0;
``````````
</details>
https://github.com/llvm/llvm-project/pull/68735
More information about the cfe-commits
mailing list