aboutsummaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexander Richardson <alexrichardson@google.com>2024-03-08 21:22:57 -0800
committerGitHub <noreply@github.com>2024-03-08 21:22:57 -0800
commitc58c8278f98c189d149d5f062b8d4f56efcada90 (patch)
treea2b86415065ae65f0da8672f81c3c4af904301f7 /compiler-rt
parent0b9ce71a256d86c08f2b52ad2e337395b8f54b41 (diff)
downloadllvm-c58c8278f98c189d149d5f062b8d4f56efcada90.zip
llvm-c58c8278f98c189d149d5f062b8d4f56efcada90.tar.gz
llvm-c58c8278f98c189d149d5f062b8d4f56efcada90.tar.bz2
[compiler-rt] Simplify and rename of operator_new_size_type
We can rely on the compiler-provided macro __SIZE_TYPE__ for all non-MSVC compilers and fall back to `uptr` otherwise. I verified via https://godbolt.org/z/MW9KMjv5f that this works for MSVC as well as GCC 4.5 Clang 3.0, so that should cover supported compilers. While touching this also rename operator_new_size_type to usize which makes it more obvious that this is the equivalent to size_t within the sanitizers runtime (which I plan to use in follow-up changes). Reviewed By: vitalybuka Pull Request: https://github.com/llvm/llvm-project/pull/83912
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h11
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h4
3 files changed, 5 insertions, 12 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 47697ef..c451fc9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -1098,7 +1098,7 @@ inline u32 GetNumberOfCPUsCached() {
} // namespace __sanitizer
-inline void *operator new(__sanitizer::operator_new_size_type size,
+inline void *operator new(__sanitizer::usize size,
__sanitizer::LowLevelAllocator &alloc) {
return alloc.Allocate(size);
}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
index 9927217..294e330 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -191,15 +191,10 @@ typedef uptr OFF_T;
#endif
typedef u64 OFF64_T;
-#if (SANITIZER_WORDSIZE == 64) || SANITIZER_APPLE
-typedef uptr operator_new_size_type;
+#ifdef __SIZE_TYPE__
+typedef __SIZE_TYPE__ usize;
#else
-# if defined(__s390__) && !defined(__s390x__)
-// Special case: 31-bit s390 has unsigned long as size_t.
-typedef unsigned long operator_new_size_type;
-# else
-typedef u32 operator_new_size_type;
-# endif
+typedef uptr usize;
#endif
typedef u64 tid_t;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h b/compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h
index 1ceb8b9..c9b917b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h
@@ -17,8 +17,6 @@
#include "sanitizer_internal_defs.h"
-inline void *operator new(__sanitizer::operator_new_size_type sz, void *p) {
- return p;
-}
+inline void *operator new(__sanitizer::usize sz, void *p) { return p; }
#endif // SANITIZER_PLACEMENT_NEW_H