[compiler-rt] [sanitizer_common] Use 38-bit mmap range for Fuchsia (PR #69387)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 14:24:29 PDT 2023


https://github.com/PiJoules updated https://github.com/llvm/llvm-project/pull/69387

>From 86cee59bd37487af8ed28678d21c3f1c74d88041 Mon Sep 17 00:00:00 2001
From: Leonard Chan <leonardchan at google.com>
Date: Tue, 17 Oct 2023 21:18:48 +0000
Subject: [PATCH] [sanitizer_common] Use 38-bit mmap range for Fuchsia

46cb8d9a325233ac11ed5e90367c43774294d87e unconditionally changed the
mmap range to 2^48 for all riscv sanitizers. This changes the allocator
tunings for the 32-bit allocator for riscv and led to a severe
performance regression for our lsan tests. This effectively revers the
tuning change but only for Fuchsia.

Once we enable the 64-bit allocator for everything riscv, this value
will be irrelevant since it's only relevant for the 32-bit allocator.
---
 compiler-rt/lib/sanitizer_common/sanitizer_platform.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 5280416f8bd3029..df446d0659f8ba9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -303,7 +303,15 @@
 #    define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 40)
 #  endif
 #elif SANITIZER_RISCV64
-#  define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
+// FIXME: Rather than hardcoding the VMA here, we should rely on
+// GetMaxUserVirtualAddress(). This will require some refactoring though since
+// many places either hardcode some value or SANITIZER_MMAP_RANGE_SIZE is
+// assumed to be some constant integer.
+#  if SANITIZER_FUCHSIA
+#    define SANITIZER_MMAP_RANGE_SIZE (1ULL << 38)
+#  else
+#    define SANITIZER_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)
+#  endif
 #elif defined(__aarch64__)
 #  if SANITIZER_APPLE
 #    if SANITIZER_OSX || SANITIZER_IOSSIM



More information about the llvm-commits mailing list