[compiler-rt] 96005d7 - [scudo] Tune FuchsiaConfig for RiscV
Caslyn Tonelli via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 13:16:17 PDT 2023
Author: Caslyn Tonelli
Date: 2023-04-17T20:15:55Z
New Revision: 96005d75b29df315f74978cb0b7602b35f663b75
URL: https://github.com/llvm/llvm-project/commit/96005d75b29df315f74978cb0b7602b35f663b75
DIFF: https://github.com/llvm/llvm-project/commit/96005d75b29df315f74978cb0b7602b35f663b75.diff
LOG: [scudo] Tune FuchsiaConfig for RiscV
Reduce `PrimaryRegionSizeLog` to 28U to be compatible with a 38bit user
address space on the fuchsia-riscv platform. `PrimaryGroupSizeLog` is
reduced to 19 to preserve 512 BatchGroups per region.
This change can be tested on Fuchsia with:
```
fx set --auto-dir bringup.riscv64 --with //bundles:boot_tests \
fx build bundles:boot_tests \
fx run-boot-test --args={-s,1} boot-libc-unittests \
--cmdline='--gtest_filter=-*DeathTest*:PthreadGetSet*:ScudoSecondaryTest*'
```
The gtest filter ignores pthread and death tests due to non-scudo
related issues on fuchsia-riscv (ScudoSecondaryTest includes a death
check).
Related Ticket: https://fxbug.dev/125263
Differential Revision: https://reviews.llvm.org/D148475
Added:
Modified:
compiler-rt/lib/scudo/standalone/allocator_config.h
compiler-rt/lib/scudo/standalone/platform.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/allocator_config.h b/compiler-rt/lib/scudo/standalone/allocator_config.h
index 64306066123e0..d06f6dfe4e0a9 100644
--- a/compiler-rt/lib/scudo/standalone/allocator_config.h
+++ b/compiler-rt/lib/scudo/standalone/allocator_config.h
@@ -169,8 +169,14 @@ struct FuchsiaConfig {
static const bool MaySupportMemoryTagging = false;
typedef SizeClassAllocator64<FuchsiaConfig> Primary;
+// Support 39-bit VMA for riscv-64
+#if SCUDO_RISCV64
+ static const uptr PrimaryRegionSizeLog = 28U;
+ static const uptr PrimaryGroupSizeLog = 19U;
+#else
static const uptr PrimaryRegionSizeLog = 30U;
static const uptr PrimaryGroupSizeLog = 21U;
+#endif
typedef u32 PrimaryCompactPtrT;
static const bool PrimaryEnableRandomOffset = true;
static const uptr PrimaryMapSizeIncrement = 1UL << 18;
diff --git a/compiler-rt/lib/scudo/standalone/platform.h b/compiler-rt/lib/scudo/standalone/platform.h
index db4217ddab9fe..aae3b9ab8760a 100644
--- a/compiler-rt/lib/scudo/standalone/platform.h
+++ b/compiler-rt/lib/scudo/standalone/platform.h
@@ -37,6 +37,12 @@
#define SCUDO_TRUSTY 0
#endif
+#if defined(__riscv) && (__riscv_xlen == 64)
+#define SCUDO_RISCV64 1
+#else
+#define SCUDO_RISCV64 0
+#endif
+
#if defined(__LP64__)
#define SCUDO_WORDSIZE 64U
#else
More information about the llvm-commits
mailing list