[compiler-rt] [nsan] Use ALIGNED instead of alignas (NFC) (PR #98933)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 00:20:15 PDT 2024
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/98933
>From 8f3f8e6d5f6b7323acfe53ed9bf30d2254895d17 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Mon, 15 Jul 2024 18:19:36 +0200
Subject: [PATCH 1/2] [nsan] Use ALIGNED instead of alignas (NFC)
When preceded by SANITIZER_INTERFACE_ATTRIBUTE, use the ALIGNED
macro instead of alignas, because clang 15 and older does not
support this. See https://clang.godbolt.org/z/Wj1193xWK.
---
compiler-rt/lib/nsan/nsan.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index e5a9b7a036e0e..4f0525a312319 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -391,23 +391,23 @@ __nsan_dump_shadow_mem(const u8 *addr, size_t size_bytes, size_t bytes_per_line,
}
SANITIZER_INTERFACE_ATTRIBUTE
-alignas(16) thread_local uptr __nsan_shadow_ret_tag = 0;
+ALIGNED(16) thread_local uptr __nsan_shadow_ret_tag = 0;
SANITIZER_INTERFACE_ATTRIBUTE
-alignas(16) thread_local char __nsan_shadow_ret_ptr[kMaxVectorWidth *
- sizeof(__float128)];
+ALIGNED(16)
+thread_local char __nsan_shadow_ret_ptr[kMaxVectorWidth * sizeof(__float128)];
SANITIZER_INTERFACE_ATTRIBUTE
-alignas(16) thread_local uptr __nsan_shadow_args_tag = 0;
+ALIGNED(16) thread_local uptr __nsan_shadow_args_tag = 0;
// Maximum number of args. This should be enough for anyone (tm). An alternate
// scheme is to have the generated code create an alloca and make
// __nsan_shadow_args_ptr point ot the alloca.
constexpr const int kMaxNumArgs = 128;
SANITIZER_INTERFACE_ATTRIBUTE
-alignas(
- 16) thread_local char __nsan_shadow_args_ptr[kMaxVectorWidth * kMaxNumArgs *
- sizeof(__float128)];
+ALIGNED(16)
+thread_local char
+ __nsan_shadow_args_ptr[kMaxVectorWidth * kMaxNumArgs * sizeof(__float128)];
enum ContinuationType { // Keep in sync with instrumentation pass.
kContinueWithShadow = 0,
>From c73c41941c33b944294112c86e9714ca3123ab2e Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 16 Jul 2024 09:18:56 +0200
Subject: [PATCH 2/2] Swap order instead
---
compiler-rt/lib/nsan/nsan.cpp | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/compiler-rt/lib/nsan/nsan.cpp b/compiler-rt/lib/nsan/nsan.cpp
index 4f0525a312319..32270601f42f8 100644
--- a/compiler-rt/lib/nsan/nsan.cpp
+++ b/compiler-rt/lib/nsan/nsan.cpp
@@ -390,24 +390,23 @@ __nsan_dump_shadow_mem(const u8 *addr, size_t size_bytes, size_t bytes_per_line,
}
}
-SANITIZER_INTERFACE_ATTRIBUTE
-ALIGNED(16) thread_local uptr __nsan_shadow_ret_tag = 0;
+alignas(16) SANITIZER_INTERFACE_ATTRIBUTE
+ thread_local uptr __nsan_shadow_ret_tag = 0;
-SANITIZER_INTERFACE_ATTRIBUTE
-ALIGNED(16)
-thread_local char __nsan_shadow_ret_ptr[kMaxVectorWidth * sizeof(__float128)];
+alignas(16) SANITIZER_INTERFACE_ATTRIBUTE
+ thread_local char __nsan_shadow_ret_ptr[kMaxVectorWidth *
+ sizeof(__float128)];
-SANITIZER_INTERFACE_ATTRIBUTE
-ALIGNED(16) thread_local uptr __nsan_shadow_args_tag = 0;
+alignas(16) SANITIZER_INTERFACE_ATTRIBUTE
+ thread_local uptr __nsan_shadow_args_tag = 0;
// Maximum number of args. This should be enough for anyone (tm). An alternate
// scheme is to have the generated code create an alloca and make
// __nsan_shadow_args_ptr point ot the alloca.
constexpr const int kMaxNumArgs = 128;
-SANITIZER_INTERFACE_ATTRIBUTE
-ALIGNED(16)
-thread_local char
- __nsan_shadow_args_ptr[kMaxVectorWidth * kMaxNumArgs * sizeof(__float128)];
+alignas(16) SANITIZER_INTERFACE_ATTRIBUTE
+ thread_local char __nsan_shadow_args_ptr[kMaxVectorWidth * kMaxNumArgs *
+ sizeof(__float128)];
enum ContinuationType { // Keep in sync with instrumentation pass.
kContinueWithShadow = 0,
More information about the llvm-commits
mailing list