diff --git a/compiler-rt/lib/scudo/standalone/allocator_config.h b/compiler-rt/lib/scudo/standalone/allocator_config.h --- a/compiler-rt/lib/scudo/standalone/allocator_config.h +++ b/compiler-rt/lib/scudo/standalone/allocator_config.h @@ -169,8 +169,14 @@ static const bool MaySupportMemoryTagging = false; typedef SizeClassAllocator64 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 --- 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