Skip to content

Commit cf8a7a6

Browse files
committed
libtsan: Update to LLVM 20.
1 parent 5ed015d commit cf8a7a6

File tree

83 files changed

+3242
-2047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3242
-2047
lines changed

lib/tsan/builtins/assembly.h

+12
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,16 @@
290290
CFI_END
291291
#endif
292292

293+
#ifdef __arm__
294+
#include "int_endianness.h"
295+
296+
#if _YUGA_BIG_ENDIAN
297+
#define VMOV_TO_DOUBLE(dst, src0, src1) vmov dst, src1, src0 SEPARATOR
298+
#define VMOV_FROM_DOUBLE(dst0, dst1, src) vmov dst1, dst0, src SEPARATOR
299+
#else
300+
#define VMOV_TO_DOUBLE(dst, src0, src1) vmov dst, src0, src1 SEPARATOR
301+
#define VMOV_FROM_DOUBLE(dst0, dst1, src) vmov dst0, dst1, src SEPARATOR
302+
#endif
303+
#endif
304+
293305
#endif // COMPILERRT_ASSEMBLY_H

lib/tsan/interception/interception.h

+14-11
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@
2525

2626
// These typedefs should be used only in the interceptor definitions to replace
2727
// the standard system types (e.g. SSIZE_T instead of ssize_t)
28-
typedef __sanitizer::uptr SIZE_T;
29-
typedef __sanitizer::sptr SSIZE_T;
28+
// On Windows the system headers (basetsd.h) provide a conflicting definition
29+
// of SIZE_T/SSIZE_T that do not match the real size_t/ssize_t for 32-bit
30+
// systems (using long instead of the expected int). Work around the typedef
31+
// redefinition by #defining SIZE_T instead of using a typedef.
32+
// TODO: We should be using __sanitizer::usize (and a new ssize) instead of
33+
// these new macros as long as we ensure they match the real system definitions.
34+
#if SANITIZER_WINDOWS
35+
// Ensure that (S)SIZE_T were already defined as we are about to override them.
36+
# include <basetsd.h>
37+
#endif
38+
39+
#define SIZE_T __sanitizer::usize
40+
#define SSIZE_T __sanitizer::ssize
3041
typedef __sanitizer::sptr PTRDIFF_T;
3142
typedef __sanitizer::s64 INTMAX_T;
3243
typedef __sanitizer::u64 UINTMAX_T;
@@ -338,16 +349,8 @@ const interpose_substitution substitution_##func_name[] \
338349
#endif
339350

340351
// ISO C++ forbids casting between pointer-to-function and pointer-to-object,
341-
// so we use casting via an integral type __interception::uptr,
342-
// assuming that system is POSIX-compliant. Using other hacks seem
343-
// challenging, as we don't even pass function type to
344-
// INTERCEPT_FUNCTION macro, only its name.
352+
// so we use casts via uintptr_t (the local __sanitizer::uptr equivalent).
345353
namespace __interception {
346-
#if defined(_WIN64)
347-
typedef unsigned long long uptr;
348-
#else
349-
typedef unsigned long uptr;
350-
#endif // _WIN64
351354

352355
#if defined(__ELF__) && !SANITIZER_FUCHSIA
353356
// The use of interceptors makes many sanitizers unusable for static linking.

lib/tsan/interception/interception_type_test.cpp

+19-12
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,35 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "interception.h"
15+
#include "sanitizer_common/sanitizer_type_traits.h"
1516

16-
#if SANITIZER_LINUX || SANITIZER_APPLE
17-
18-
#include <sys/types.h>
17+
#if __has_include(<sys/types.h>)
18+
# include <sys/types.h>
19+
#endif
1920
#include <stddef.h>
2021
#include <stdint.h>
2122

22-
COMPILER_CHECK(sizeof(::SIZE_T) == sizeof(size_t));
23-
COMPILER_CHECK(sizeof(::SSIZE_T) == sizeof(ssize_t));
24-
COMPILER_CHECK(sizeof(::PTRDIFF_T) == sizeof(ptrdiff_t));
23+
COMPILER_CHECK((__sanitizer::is_same<__sanitizer::uptr, ::uintptr_t>::value));
24+
COMPILER_CHECK((__sanitizer::is_same<__sanitizer::sptr, ::intptr_t>::value));
25+
COMPILER_CHECK((__sanitizer::is_same<__sanitizer::usize, ::size_t>::value));
26+
COMPILER_CHECK((__sanitizer::is_same<::PTRDIFF_T, ::ptrdiff_t>::value));
27+
COMPILER_CHECK((__sanitizer::is_same<::SIZE_T, ::size_t>::value));
28+
#if !SANITIZER_WINDOWS
29+
// No ssize_t on Windows.
30+
COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value));
31+
#endif
32+
// TODO: These are not actually the same type on Linux (long vs long long)
2533
COMPILER_CHECK(sizeof(::INTMAX_T) == sizeof(intmax_t));
34+
COMPILER_CHECK(sizeof(::UINTMAX_T) == sizeof(uintmax_t));
2635

27-
# if SANITIZER_GLIBC || SANITIZER_ANDROID
36+
#if SANITIZER_GLIBC || SANITIZER_ANDROID
2837
COMPILER_CHECK(sizeof(::OFF64_T) == sizeof(off64_t));
29-
# endif
38+
#endif
3039

3140
// The following are the cases when pread (and friends) is used instead of
3241
// pread64. In those cases we need OFF_T to match off_t. We don't care about the
3342
// rest (they depend on _FILE_OFFSET_BITS setting when building an application).
34-
# if SANITIZER_ANDROID || !defined _FILE_OFFSET_BITS || \
35-
_FILE_OFFSET_BITS != 64
43+
#if !SANITIZER_WINDOWS && (SANITIZER_ANDROID || !defined _FILE_OFFSET_BITS || \
44+
_FILE_OFFSET_BITS != 64)
3645
COMPILER_CHECK(sizeof(::OFF_T) == sizeof(off_t));
37-
# endif
38-
3946
#endif

0 commit comments

Comments
 (0)