[compiler-rt] eef39f4 - [NFC][asan] Inline ENSURE_ASAN_INITED macro (#74174)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 14:58:55 PST 2023
Author: Vitaly Buka
Date: 2023-12-04T14:58:51-08:00
New Revision: eef39f4341b16d1eb5d1a907d2cefe061f3a8928
URL: https://github.com/llvm/llvm-project/commit/eef39f4341b16d1eb5d1a907d2cefe061f3a8928
DIFF: https://github.com/llvm/llvm-project/commit/eef39f4341b16d1eb5d1a907d2cefe061f3a8928.diff
LOG: [NFC][asan] Inline ENSURE_ASAN_INITED macro (#74174)
Added:
Modified:
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_interceptors.h
compiler-rt/lib/asan/asan_malloc_linux.cpp
compiler-rt/lib/asan/asan_malloc_mac.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 1a1a26a7cd8bf..4de2fa356374a 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -196,7 +196,10 @@ static int munmap_interceptor(Munmap real_munmap, void *addr, SIZE_T length) {
__lsan::ScopedInterceptorDisabler disabler
#endif
-# define SIGNAL_INTERCEPTOR_ENTER() ENSURE_ASAN_INITED()
+# define SIGNAL_INTERCEPTOR_ENTER() \
+ do { \
+ AsanInitFromRtl(); \
+ } while (false)
# include "sanitizer_common/sanitizer_common_interceptors.inc"
# include "sanitizer_common/sanitizer_signal_interceptors.inc"
@@ -496,7 +499,7 @@ DEFINE_REAL(char*, index, const char *string, int c)
INTERCEPTOR(char *, strcat, char *to, const char *from) {
void *ctx;
ASAN_INTERCEPTOR_ENTER(ctx, strcat);
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_length = internal_strlen(from);
ASAN_READ_RANGE(ctx, from, from_length + 1);
@@ -517,7 +520,7 @@ DEFINE_REAL(char*, index, const char *string, int c)
INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) {
void *ctx;
ASAN_INTERCEPTOR_ENTER(ctx, strncat);
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_length = MaybeRealStrnlen(from, size);
uptr copy_length = Min(size, from_length + 1);
@@ -594,7 +597,7 @@ INTERCEPTOR(char*, __strdup, const char *s) {
INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) {
void *ctx;
ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
@@ -620,7 +623,7 @@ static ALWAYS_INLINE auto StrtolImpl(void *ctx, Fn real, const char *nptr,
INTERCEPTOR(ret_type, func, const char *nptr, char **endptr, int base) { \
void *ctx; \
ASAN_INTERCEPTOR_ENTER(ctx, func); \
- ENSURE_ASAN_INITED(); \
+ AsanInitFromRtl(); \
return StrtolImpl(ctx, REAL(func), nptr, endptr, base); \
}
@@ -637,7 +640,7 @@ INTERCEPTOR(int, atoi, const char *nptr) {
ASAN_INTERCEPTOR_ENTER(ctx, atoi);
if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
return REAL(atoi)(nptr);
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
if (!flags()->replace_str) {
return REAL(atoi)(nptr);
}
@@ -657,7 +660,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
ASAN_INTERCEPTOR_ENTER(ctx, atol);
if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
return REAL(atol)(nptr);
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
if (!flags()->replace_str) {
return REAL(atol)(nptr);
}
@@ -671,7 +674,7 @@ INTERCEPTOR(long, atol, const char *nptr) {
INTERCEPTOR(long long, atoll, const char *nptr) {
void *ctx;
ASAN_INTERCEPTOR_ENTER(ctx, atoll);
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
if (!flags()->replace_str) {
return REAL(atoll)(nptr);
}
@@ -694,8 +697,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
void *dso_handle) {
if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
return REAL(__cxa_atexit)(func, arg, dso_handle);
- ENSURE_ASAN_INITED();
-#if CAN_SANITIZE_LEAKS
+ AsanInitFromRtl();
+# if CAN_SANITIZE_LEAKS
__lsan::ScopedInterceptorDisabler disabler;
#endif
int res = REAL(__cxa_atexit)(func, arg, dso_handle);
@@ -706,8 +709,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg,
#if ASAN_INTERCEPT_ATEXIT
INTERCEPTOR(int, atexit, void (*func)()) {
- ENSURE_ASAN_INITED();
-#if CAN_SANITIZE_LEAKS
+ AsanInitFromRtl();
+# if CAN_SANITIZE_LEAKS
__lsan::ScopedInterceptorDisabler disabler;
#endif
// Avoid calling real atexit as it is unreachable on at least on Linux.
diff --git a/compiler-rt/lib/asan/asan_interceptors.h b/compiler-rt/lib/asan/asan_interceptors.h
index 6a7748c8f9bb9..826b45f5ada8c 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -24,11 +24,6 @@ namespace __asan {
void InitializeAsanInterceptors();
void InitializePlatformInterceptors();
-#define ENSURE_ASAN_INITED() \
- do { \
- AsanInitFromRtl(); \
- } while (0)
-
} // namespace __asan
// There is no general interception at all on Fuchsia.
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index eb29233c3cf82..d426b923c94ed 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp
@@ -85,7 +85,7 @@ INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
#if SANITIZER_INTERCEPT_REALLOCARRAY
INTERCEPTOR(void*, reallocarray, void *ptr, uptr nmemb, uptr size) {
- ENSURE_ASAN_INITED();
+ AsanInitFromRtl();
GET_STACK_TRACE_MALLOC;
return asan_reallocarray(ptr, nmemb, size, &stack);
}
diff --git a/compiler-rt/lib/asan/asan_malloc_mac.cpp b/compiler-rt/lib/asan/asan_malloc_mac.cpp
index d2380ee62bf3d..f25d7e1901536 100644
--- a/compiler-rt/lib/asan/asan_malloc_mac.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_mac.cpp
@@ -22,7 +22,10 @@
using namespace __asan;
#define COMMON_MALLOC_ZONE_NAME "asan"
-#define COMMON_MALLOC_ENTER() ENSURE_ASAN_INITED()
+# define COMMON_MALLOC_ENTER() \
+ do { \
+ AsanInitFromRtl(); \
+ } while (false)
# define COMMON_MALLOC_SANITIZER_INITIALIZED AsanInited()
# define COMMON_MALLOC_FORCE_LOCK() asan_mz_force_lock()
# define COMMON_MALLOC_FORCE_UNLOCK() asan_mz_force_unlock()
More information about the llvm-commits
mailing list