Skip to content

Commit d029d5f

Browse files
MaskRayyuxuanchen1997
authored andcommitted
[tsan] Replace ALIGNED with alignas
Summary: Similar to #98958. The relands 656f617 , which was reverted due to an issue in tsan_platform_mac.cpp Pull Request: #98959 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250841
1 parent de6e141 commit d029d5f

8 files changed

+15
-16
lines changed

compiler-rt/lib/tsan/rtl/tsan_defs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# define __MM_MALLOC_H
3131
# include <emmintrin.h>
3232
# include <smmintrin.h>
33-
# define VECTOR_ALIGNED ALIGNED(16)
33+
# define VECTOR_ALIGNED alignas(16)
3434
typedef __m128i m128;
3535
#else
3636
# define VECTOR_ALIGNED

compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct AtExitCtx {
208208
struct InterceptorContext {
209209
// The object is 64-byte aligned, because we want hot data to be located
210210
// in a single cache line if possible (it's accessed in every interceptor).
211-
ALIGNED(64) LibIgnore libignore;
211+
alignas(64) LibIgnore libignore;
212212
__sanitizer_sigaction sigactions[kSigCount];
213213
#if !SANITIZER_APPLE && !SANITIZER_NETBSD
214214
unsigned finalize_key;
@@ -220,7 +220,7 @@ struct InterceptorContext {
220220
InterceptorContext() : libignore(LINKER_INITIALIZED), atexit_mu(MutexTypeAtExit), AtExitStack() {}
221221
};
222222

223-
static ALIGNED(64) char interceptor_placeholder[sizeof(InterceptorContext)];
223+
alignas(64) static char interceptor_placeholder[sizeof(InterceptorContext)];
224224
InterceptorContext *interceptor_ctx() {
225225
return reinterpret_cast<InterceptorContext*>(&interceptor_placeholder[0]);
226226
}

compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct DynamicAnnContext {
7676
};
7777

7878
static DynamicAnnContext *dyn_ann_ctx;
79-
static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)] ALIGNED(64);
79+
alignas(64) static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)];
8080

8181
static void AddExpectRace(ExpectRace *list,
8282
char *f, int l, uptr addr, uptr size, char *desc) {

compiler-rt/lib/tsan/rtl/tsan_mman.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct MapUnmapCallback {
5454
}
5555
};
5656

57-
static char allocator_placeholder[sizeof(Allocator)] ALIGNED(64);
57+
alignas(64) static char allocator_placeholder[sizeof(Allocator)];
5858
Allocator *allocator() {
5959
return reinterpret_cast<Allocator*>(&allocator_placeholder);
6060
}
@@ -75,7 +75,7 @@ struct GlobalProc {
7575
internal_alloc_mtx(MutexTypeInternalAlloc) {}
7676
};
7777

78-
static char global_proc_placeholder[sizeof(GlobalProc)] ALIGNED(64);
78+
alignas(64) static char global_proc_placeholder[sizeof(GlobalProc)];
7979
GlobalProc *global_proc() {
8080
return reinterpret_cast<GlobalProc*>(&global_proc_placeholder);
8181
}

compiler-rt/lib/tsan/rtl/tsan_rtl.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ int (*on_finalize)(int);
4848
#endif
4949

5050
#if !SANITIZER_GO && !SANITIZER_APPLE
51-
__attribute__((tls_model("initial-exec")))
52-
THREADLOCAL char cur_thread_placeholder[sizeof(ThreadState)] ALIGNED(
53-
SANITIZER_CACHE_LINE_SIZE);
51+
alignas(SANITIZER_CACHE_LINE_SIZE) THREADLOCAL __attribute__((tls_model(
52+
"initial-exec"))) char cur_thread_placeholder[sizeof(ThreadState)];
5453
#endif
55-
static char ctx_placeholder[sizeof(Context)] ALIGNED(SANITIZER_CACHE_LINE_SIZE);
54+
alignas(SANITIZER_CACHE_LINE_SIZE) static char ctx_placeholder[sizeof(Context)];
5655
Context *ctx;
5756

5857
// Can be overriden by a front-end.

compiler-rt/lib/tsan/rtl/tsan_rtl.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct TidEpoch {
136136
Epoch epoch;
137137
};
138138

139-
struct TidSlot {
139+
struct alignas(SANITIZER_CACHE_LINE_SIZE) TidSlot {
140140
Mutex mtx;
141141
Sid sid;
142142
atomic_uint32_t raw_epoch;
@@ -153,10 +153,10 @@ struct TidSlot {
153153
}
154154

155155
TidSlot();
156-
} ALIGNED(SANITIZER_CACHE_LINE_SIZE);
156+
};
157157

158158
// This struct is stored in TLS.
159-
struct ThreadState {
159+
struct alignas(SANITIZER_CACHE_LINE_SIZE) ThreadState {
160160
FastState fast_state;
161161
int ignore_sync;
162162
#if !SANITIZER_GO
@@ -234,7 +234,7 @@ struct ThreadState {
234234
const ReportDesc *current_report;
235235

236236
explicit ThreadState(Tid tid);
237-
} ALIGNED(SANITIZER_CACHE_LINE_SIZE);
237+
};
238238

239239
#if !SANITIZER_GO
240240
#if SANITIZER_APPLE || SANITIZER_ANDROID

compiler-rt/lib/tsan/rtl/tsan_suppressions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const char *__tsan_default_suppressions() {
4242

4343
namespace __tsan {
4444

45-
ALIGNED(64) static char suppression_placeholder[sizeof(SuppressionContext)];
45+
alignas(64) static char suppression_placeholder[sizeof(SuppressionContext)];
4646
static SuppressionContext *suppression_ctx = nullptr;
4747
static const char *kSuppressionTypes[] = {
4848
kSuppressionRace, kSuppressionRaceTop, kSuppressionMutex,

compiler-rt/lib/tsan/rtl/tsan_vector_clock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class VectorClock {
3434
VectorClock& operator=(const VectorClock& other);
3535

3636
private:
37-
Epoch clk_[kThreadSlotCount] VECTOR_ALIGNED;
37+
VECTOR_ALIGNED Epoch clk_[kThreadSlotCount];
3838
};
3939

4040
ALWAYS_INLINE Epoch VectorClock::Get(Sid sid) const {

0 commit comments

Comments
 (0)