Skip to content

Commit bd77573

Browse files
mysterymathfhahn
authored andcommitted
Revert "[tsan] Replace ALIGNED with alignas" (llvm#99240)
Reverts llvm#98959 Cherry-picked ahead of time to unblock auto-merger due to build failures rdar://132463432
1 parent 87a385d commit bd77573

9 files changed

+17
-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 alignas(16)
33+
# define VECTOR_ALIGNED ALIGNED(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-
alignas(64) LibIgnore libignore;
211+
ALIGNED(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-
alignas(64) static char interceptor_placeholder[sizeof(InterceptorContext)];
223+
static ALIGNED(64) 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-
alignas(64) static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)];
79+
static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)] ALIGNED(64);
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-
alignas(64) static char allocator_placeholder[sizeof(Allocator)];
57+
static char allocator_placeholder[sizeof(Allocator)] ALIGNED(64);
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-
alignas(64) static char global_proc_placeholder[sizeof(GlobalProc)];
78+
static char global_proc_placeholder[sizeof(GlobalProc)] ALIGNED(64);
7979
GlobalProc *global_proc() {
8080
return reinterpret_cast<GlobalProc*>(&global_proc_placeholder);
8181
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
namespace __tsan {
4747

4848
#if !SANITIZER_GO
49-
static char main_thread_state[sizeof(ThreadState)] alignas(
49+
static char main_thread_state[sizeof(ThreadState)] ALIGNED(
5050
SANITIZER_CACHE_LINE_SIZE);
5151
static ThreadState *dead_thread_state;
5252
static pthread_key_t thread_state_key;

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

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

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

5758
// 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 alignas(SANITIZER_CACHE_LINE_SIZE) TidSlot {
139+
struct TidSlot {
140140
Mutex mtx;
141141
Sid sid;
142142
atomic_uint32_t raw_epoch;
@@ -153,10 +153,10 @@ struct alignas(SANITIZER_CACHE_LINE_SIZE) TidSlot {
153153
}
154154

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

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

236236
explicit ThreadState(Tid tid);
237-
};
237+
} ALIGNED(SANITIZER_CACHE_LINE_SIZE);
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-
alignas(64) static char suppression_placeholder[sizeof(SuppressionContext)];
45+
ALIGNED(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-
VECTOR_ALIGNED Epoch clk_[kThreadSlotCount];
37+
Epoch clk_[kThreadSlotCount] VECTOR_ALIGNED;
3838
};
3939

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

0 commit comments

Comments
 (0)