[PATCH] D92403: [LSan][RISCV] Enable LSan for RISCV64
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG2de4f19ecdb2: [LSan][RISCV] Enable LSan for RISCV64 (authored by luismarques). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92403/new/ https://reviews.llvm.org/D92403 Files: clang/lib/Driver/ToolChains/Linux.cpp clang/test/Driver/fsanitize.c compiler-rt/cmake/config-ix.cmake compiler-rt/lib/lsan/lsan_allocator.h compiler-rt/lib/lsan/lsan_common.h compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h compiler-rt/test/asan/lit.cfg.py compiler-rt/test/lsan/TestCases/use_registers.cpp compiler-rt/test/lsan/lit.common.cfg.py compiler-rt/test/sanitizer_common/print_address.h Index: compiler-rt/test/sanitizer_common/print_address.h === --- compiler-rt/test/sanitizer_common/print_address.h +++ compiler-rt/test/sanitizer_common/print_address.h @@ -8,7 +8,7 @@ while (n--) { void *p = va_arg(ap, void *); #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ -defined(__s390x__) +defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "0x%012lx ", (unsigned long) p); Index: compiler-rt/test/lsan/lit.common.cfg.py === --- compiler-rt/test/lsan/lit.common.cfg.py +++ compiler-rt/test/lsan/lit.common.cfg.py @@ -76,7 +76,7 @@ # LeakSanitizer tests are currently supported on # Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin. supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features -supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l', 's390x'] +supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x'] supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64'] supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386'] if not (supported_android or supported_linux or supported_darwin or supported_netbsd): Index: compiler-rt/test/lsan/TestCases/use_registers.cpp === --- compiler-rt/test/lsan/TestCases/use_registers.cpp +++ compiler-rt/test/lsan/TestCases/use_registers.cpp @@ -50,6 +50,10 @@ asm("lgr %%r10, %0" : : "r"(p)); +#elif defined(__riscv) + asm("mv s11, %0" + : + : "r"(p)); #else #error "Test is not supported on this architecture." #endif Index: compiler-rt/test/asan/lit.cfg.py === --- compiler-rt/test/asan/lit.cfg.py +++ compiler-rt/test/asan/lit.cfg.py @@ -210,7 +210,7 @@ # Turn on leak detection on 64-bit Linux. leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64']) -leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386']) +leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64']) leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64') leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386']) if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd: Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h === --- compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -486,7 +486,7 @@ (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_RTEMS) #define SANITIZER_INTERCEPT___LIBC_MEMALIGN SI_GLIBC #define SANITIZER_INTERCEPT_PVALLOC (SI_GLIBC || SI_ANDROID) -#define SANITIZER_INTERCEPT_CFREE SI_GLIBC +#define SANITIZER_INTERCEPT_CFREE (SI_GLIBC && !SANITIZER_RISCV64) #define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX #define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC && SI_NOT_RTEMS) #define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD) Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp =
[PATCH] D92403: [LSan][RISCV] Enable LSan for RISCV64
luismarques updated this revision to Diff 320375. luismarques added a comment. Herald added a subscriber: vkmr. Rebase and address formatting issues. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92403/new/ https://reviews.llvm.org/D92403 Files: clang/lib/Driver/ToolChains/Linux.cpp clang/test/Driver/fsanitize.c compiler-rt/cmake/config-ix.cmake compiler-rt/lib/lsan/lsan_allocator.h compiler-rt/lib/lsan/lsan_common.h compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h compiler-rt/test/asan/lit.cfg.py compiler-rt/test/lsan/TestCases/use_registers.cpp compiler-rt/test/lsan/lit.common.cfg.py compiler-rt/test/sanitizer_common/print_address.h Index: compiler-rt/test/sanitizer_common/print_address.h === --- compiler-rt/test/sanitizer_common/print_address.h +++ compiler-rt/test/sanitizer_common/print_address.h @@ -8,7 +8,7 @@ while (n--) { void *p = va_arg(ap, void *); #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ -defined(__s390x__) +defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "0x%012lx ", (unsigned long) p); Index: compiler-rt/test/lsan/lit.common.cfg.py === --- compiler-rt/test/lsan/lit.common.cfg.py +++ compiler-rt/test/lsan/lit.common.cfg.py @@ -76,7 +76,7 @@ # LeakSanitizer tests are currently supported on # Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin. supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features -supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l', 's390x'] +supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x'] supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64'] supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386'] if not (supported_android or supported_linux or supported_darwin or supported_netbsd): Index: compiler-rt/test/lsan/TestCases/use_registers.cpp === --- compiler-rt/test/lsan/TestCases/use_registers.cpp +++ compiler-rt/test/lsan/TestCases/use_registers.cpp @@ -50,6 +50,10 @@ asm("lgr %%r10, %0" : : "r"(p)); +#elif defined(__riscv) + asm("mv s11, %0" + : + : "r"(p)); #else #error "Test is not supported on this architecture." #endif Index: compiler-rt/test/asan/lit.cfg.py === --- compiler-rt/test/asan/lit.cfg.py +++ compiler-rt/test/asan/lit.cfg.py @@ -210,7 +210,7 @@ # Turn on leak detection on 64-bit Linux. leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64']) -leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386']) +leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64']) leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64') leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386']) if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd: Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h === --- compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -486,7 +486,7 @@ (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_RTEMS) #define SANITIZER_INTERCEPT___LIBC_MEMALIGN SI_GLIBC #define SANITIZER_INTERCEPT_PVALLOC (SI_GLIBC || SI_ANDROID) -#define SANITIZER_INTERCEPT_CFREE SI_GLIBC +#define SANITIZER_INTERCEPT_CFREE (SI_GLIBC && !SANITIZER_RISCV64) #define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX #define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC && SI_NOT_RTEMS) #define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD) Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp === --- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ c
[PATCH] D92403: [LSan][RISCV] Enable LSan for RISCV64
MaskRay accepted this revision. MaskRay added inline comments. Comment at: compiler-rt/test/sanitizer_common/print_address.h:11 #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ -defined(__s390x__) +defined(__s390x__) || (defined(__riscv) && (__riscv_xlen == 64)) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not `(__riscv_xlen == 64)` the paren is redundant Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92403/new/ https://reviews.llvm.org/D92403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D92403: [LSan][RISCV] Enable LSan for RISCV64
luismarques updated this revision to Diff 308737. luismarques added a comment. Fix formatting. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92403/new/ https://reviews.llvm.org/D92403 Files: clang/lib/Driver/ToolChains/Linux.cpp clang/test/Driver/fsanitize.c compiler-rt/cmake/config-ix.cmake compiler-rt/lib/lsan/lsan_allocator.h compiler-rt/lib/lsan/lsan_common.h compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h compiler-rt/test/asan/lit.cfg.py compiler-rt/test/lsan/TestCases/use_registers.cpp compiler-rt/test/lsan/lit.common.cfg.py compiler-rt/test/sanitizer_common/print_address.h Index: compiler-rt/test/sanitizer_common/print_address.h === --- compiler-rt/test/sanitizer_common/print_address.h +++ compiler-rt/test/sanitizer_common/print_address.h @@ -8,7 +8,7 @@ while (n--) { void *p = va_arg(ap, void *); #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ -defined(__s390x__) +defined(__s390x__) || (defined(__riscv) && (__riscv_xlen == 64)) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "0x%012lx ", (unsigned long) p); Index: compiler-rt/test/lsan/lit.common.cfg.py === --- compiler-rt/test/lsan/lit.common.cfg.py +++ compiler-rt/test/lsan/lit.common.cfg.py @@ -76,7 +76,7 @@ # LeakSanitizer tests are currently supported on # Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin. supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features -supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l', 's390x'] +supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x'] supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64'] supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386'] if not (supported_android or supported_linux or supported_darwin or supported_netbsd): Index: compiler-rt/test/lsan/TestCases/use_registers.cpp === --- compiler-rt/test/lsan/TestCases/use_registers.cpp +++ compiler-rt/test/lsan/TestCases/use_registers.cpp @@ -50,6 +50,10 @@ asm("lgr %%r10, %0" : : "r"(p)); +#elif defined(__riscv) + asm("mv s11, %0" + : + : "r"(p)); #else #error "Test is not supported on this architecture." #endif Index: compiler-rt/test/asan/lit.cfg.py === --- compiler-rt/test/asan/lit.cfg.py +++ compiler-rt/test/asan/lit.cfg.py @@ -210,7 +210,7 @@ # Turn on leak detection on 64-bit Linux. leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64']) -leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386']) +leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64']) leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64') leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386']) if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd: Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h === --- compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -492,7 +492,7 @@ !SI_SOLARIS) // NOLINT #define SANITIZER_INTERCEPT_CFREE\ (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_FUCHSIA && SI_NOT_RTEMS && \ - !SI_SOLARIS && !SANITIZER_ANDROID) // NOLINT + !SI_SOLARIS && !SANITIZER_ANDROID && !SANITIZER_RISCV64) // NOLINT #define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX #define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC && SI_NOT_RTEMS) #define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD) Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp === --- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ compiler-rt/lib/sanitizer_comm
[PATCH] D92403: [LSan][RISCV] Enable LSan for RISCV64
luismarques created this revision. luismarques added reviewers: asb, lenary, vitalybuka, eugenis, EccoTheDolphin. Herald added subscribers: Sanitizers, cfe-commits, NickHung, evandro, sameer.abuasal, s.egerton, Jim, benna, psnobl, PkmX, rogfer01, shiva0217, kito-cheng, simoncook, fedor.sergeev, mgorny. Herald added projects: clang, Sanitizers. luismarques requested review of this revision. Fixes the broken RISCV64 implementation of `internal_clone` and adds RISCV64 support for LSan. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D92403 Files: clang/lib/Driver/ToolChains/Linux.cpp clang/test/Driver/fsanitize.c compiler-rt/cmake/config-ix.cmake compiler-rt/lib/lsan/lsan_allocator.h compiler-rt/lib/lsan/lsan_common.h compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h compiler-rt/test/asan/lit.cfg.py compiler-rt/test/lsan/TestCases/use_registers.cpp compiler-rt/test/lsan/lit.common.cfg.py compiler-rt/test/sanitizer_common/print_address.h Index: compiler-rt/test/sanitizer_common/print_address.h === --- compiler-rt/test/sanitizer_common/print_address.h +++ compiler-rt/test/sanitizer_common/print_address.h @@ -8,7 +8,7 @@ while (n--) { void *p = va_arg(ap, void *); #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \ -defined(__s390x__) +defined(__s390x__) || (defined(__riscv) && (__riscv_xlen == 64)) // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "0x%012lx ", (unsigned long) p); Index: compiler-rt/test/lsan/lit.common.cfg.py === --- compiler-rt/test/lsan/lit.common.cfg.py +++ compiler-rt/test/lsan/lit.common.cfg.py @@ -76,7 +76,7 @@ # LeakSanitizer tests are currently supported on # Android{aarch64, x86, x86_64}, x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin. supported_android = config.android and config.target_arch in ['x86_64', 'i386', 'aarch64'] and 'android-thread-properties-api' in config.available_features -supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l', 's390x'] +supported_linux = (not config.android) and config.host_os == 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'riscv64', 'arm', 'armhf', 'armv7l', 's390x'] supported_darwin = config.host_os == 'Darwin' and config.target_arch in ['x86_64'] supported_netbsd = config.host_os == 'NetBSD' and config.target_arch in ['x86_64', 'i386'] if not (supported_android or supported_linux or supported_darwin or supported_netbsd): Index: compiler-rt/test/lsan/TestCases/use_registers.cpp === --- compiler-rt/test/lsan/TestCases/use_registers.cpp +++ compiler-rt/test/lsan/TestCases/use_registers.cpp @@ -50,6 +50,10 @@ asm("lgr %%r10, %0" : : "r"(p)); +#elif defined(__riscv) + asm("mv s11, %0" + : + : "r"(p)); #else #error "Test is not supported on this architecture." #endif Index: compiler-rt/test/asan/lit.cfg.py === --- compiler-rt/test/asan/lit.cfg.py +++ compiler-rt/test/asan/lit.cfg.py @@ -210,7 +210,7 @@ # Turn on leak detection on 64-bit Linux. leak_detection_android = config.android and 'android-thread-properties-api' in config.available_features and (config.target_arch in ['x86_64', 'i386', 'i686', 'aarch64']) -leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386']) +leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch in ['x86_64', 'i386', 'riscv64']) leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64') leak_detection_netbsd = (config.host_os == 'NetBSD') and (config.target_arch in ['x86_64', 'i386']) if leak_detection_android or leak_detection_linux or leak_detection_mac or leak_detection_netbsd: Index: compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h === --- compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -492,7 +492,7 @@ !SI_SOLARIS) // NOLINT #define SANITIZER_INTERCEPT_CFREE\ (!SI_FREEBSD && !SI_MAC && !SI_NETBSD && SI_NOT_FUCHSIA && SI_NOT_RTEMS && \ - !SI_SOLARIS && !SANITIZER_ANDROID) // NOLINT + !SI_SOLARIS && !SANITIZER_ANDROID && !SANITIZER_RISCV64) // NOLINT #define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX #define SANITIZER_INTERCEPT_A