Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tsan] Replace ALIGNED with alignas #98959

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# define __MM_MALLOC_H
# include <emmintrin.h>
# include <smmintrin.h>
# define VECTOR_ALIGNED ALIGNED(16)
# define VECTOR_ALIGNED alignas(16)
typedef __m128i m128;
#else
# define VECTOR_ALIGNED
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ struct AtExitCtx {
struct InterceptorContext {
// The object is 64-byte aligned, because we want hot data to be located
// in a single cache line if possible (it's accessed in every interceptor).
ALIGNED(64) LibIgnore libignore;
alignas(64) LibIgnore libignore;
__sanitizer_sigaction sigactions[kSigCount];
#if !SANITIZER_APPLE && !SANITIZER_NETBSD
unsigned finalize_key;
Expand All @@ -220,7 +220,7 @@ struct InterceptorContext {
InterceptorContext() : libignore(LINKER_INITIALIZED), atexit_mu(MutexTypeAtExit), AtExitStack() {}
};

static ALIGNED(64) char interceptor_placeholder[sizeof(InterceptorContext)];
alignas(64) static char interceptor_placeholder[sizeof(InterceptorContext)];
InterceptorContext *interceptor_ctx() {
return reinterpret_cast<InterceptorContext*>(&interceptor_placeholder[0]);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct DynamicAnnContext {
};

static DynamicAnnContext *dyn_ann_ctx;
static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)] ALIGNED(64);
alignas(64) static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)];

static void AddExpectRace(ExpectRace *list,
char *f, int l, uptr addr, uptr size, char *desc) {
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/tsan/rtl/tsan_mman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct MapUnmapCallback {
}
};

static char allocator_placeholder[sizeof(Allocator)] ALIGNED(64);
alignas(64) static char allocator_placeholder[sizeof(Allocator)];
Allocator *allocator() {
return reinterpret_cast<Allocator*>(&allocator_placeholder);
}
Expand All @@ -75,7 +75,7 @@ struct GlobalProc {
internal_alloc_mtx(MutexTypeInternalAlloc) {}
};

static char global_proc_placeholder[sizeof(GlobalProc)] ALIGNED(64);
alignas(64) static char global_proc_placeholder[sizeof(GlobalProc)];
GlobalProc *global_proc() {
return reinterpret_cast<GlobalProc*>(&global_proc_placeholder);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
namespace __tsan {

#if !SANITIZER_GO
static char main_thread_state[sizeof(ThreadState)] ALIGNED(
static char main_thread_state[sizeof(ThreadState)] alignas(
SANITIZER_CACHE_LINE_SIZE);
static ThreadState *dead_thread_state;
static pthread_key_t thread_state_key;
Expand Down
7 changes: 3 additions & 4 deletions compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ int (*on_finalize)(int);
#endif

#if !SANITIZER_GO && !SANITIZER_APPLE
__attribute__((tls_model("initial-exec")))
THREADLOCAL char cur_thread_placeholder[sizeof(ThreadState)] ALIGNED(
SANITIZER_CACHE_LINE_SIZE);
alignas(SANITIZER_CACHE_LINE_SIZE) THREADLOCAL __attribute__((tls_model(
"initial-exec"))) char cur_thread_placeholder[sizeof(ThreadState)];
#endif
static char ctx_placeholder[sizeof(Context)] ALIGNED(SANITIZER_CACHE_LINE_SIZE);
alignas(SANITIZER_CACHE_LINE_SIZE) static char ctx_placeholder[sizeof(Context)];
Context *ctx;

// Can be overriden by a front-end.
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/lib/tsan/rtl/tsan_rtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct TidEpoch {
Epoch epoch;
};

struct TidSlot {
struct alignas(SANITIZER_CACHE_LINE_SIZE) TidSlot {
Mutex mtx;
Sid sid;
atomic_uint32_t raw_epoch;
Expand All @@ -153,10 +153,10 @@ struct TidSlot {
}

TidSlot();
} ALIGNED(SANITIZER_CACHE_LINE_SIZE);
};

// This struct is stored in TLS.
struct ThreadState {
struct alignas(SANITIZER_CACHE_LINE_SIZE) ThreadState {
FastState fast_state;
int ignore_sync;
#if !SANITIZER_GO
Expand Down Expand Up @@ -234,7 +234,7 @@ struct ThreadState {
const ReportDesc *current_report;

explicit ThreadState(Tid tid);
} ALIGNED(SANITIZER_CACHE_LINE_SIZE);
};

#if !SANITIZER_GO
#if SANITIZER_APPLE || SANITIZER_ANDROID
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const char *__tsan_default_suppressions() {

namespace __tsan {

ALIGNED(64) static char suppression_placeholder[sizeof(SuppressionContext)];
alignas(64) static char suppression_placeholder[sizeof(SuppressionContext)];
static SuppressionContext *suppression_ctx = nullptr;
static const char *kSuppressionTypes[] = {
kSuppressionRace, kSuppressionRaceTop, kSuppressionMutex,
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_vector_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class VectorClock {
VectorClock& operator=(const VectorClock& other);

private:
Epoch clk_[kThreadSlotCount] VECTOR_ALIGNED;
VECTOR_ALIGNED Epoch clk_[kThreadSlotCount];
};

ALWAYS_INLINE Epoch VectorClock::Get(Sid sid) const {
Expand Down
Loading