[compiler-rt] eae8d93 - [sanitizer] Add GetMaxVirtualAddress() support for LoongArch

Weining Lu via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 21:33:28 PST 2022


Author: Youling Tang
Date: 2022-11-10T13:32:30+08:00
New Revision: eae8d93dc26837c2aa5764b7761e4d475b154081

URL: https://github.com/llvm/llvm-project/commit/eae8d93dc26837c2aa5764b7761e4d475b154081
DIFF: https://github.com/llvm/llvm-project/commit/eae8d93dc26837c2aa5764b7761e4d475b154081.diff

LOG: [sanitizer] Add GetMaxVirtualAddress() support for LoongArch

Add support for getting the maximum virtual address, LoongArch has multiple
address space layouts, the default maximum virtual address of the current
user space is 47 bits. (from TASK_SIZE in the kernel for loongarch64).

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137219

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index dc2ea933fadc7..5d1bf95396039 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1105,7 +1105,7 @@ uptr GetMaxVirtualAddress() {
 #if SANITIZER_NETBSD && defined(__x86_64__)
   return 0x7f7ffffff000ULL;  // (0x00007f8000000000 - PAGE_SIZE)
 #elif SANITIZER_WORDSIZE == 64
-# if defined(__powerpc64__) || defined(__aarch64__)
+# if defined(__powerpc64__) || defined(__aarch64__) || defined(__loongarch__)
   // On PowerPC64 we have two 
diff erent address space layouts: 44- and 46-bit.
   // We somehow need to figure out which one we are using now and choose
   // one of 0x00000fffffffffffUL and 0x00003fffffffffffUL.
@@ -1113,6 +1113,7 @@ uptr GetMaxVirtualAddress() {
   // of the address space, so simply checking the stack address is not enough.
   // This should (does) work for both PowerPC64 Endian modes.
   // Similarly, aarch64 has multiple address space layouts: 39, 42 and 47-bit.
+  // loongarch64 also has multiple address space layouts: default is 47-bit.
   return (1ULL << (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1)) - 1;
 #elif SANITIZER_RISCV64
   return (1ULL << 38) - 1;


        


More information about the llvm-commits mailing list