[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

Michał Górny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 23 07:13:53 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL350029: [xray] Disable alignas() for thread_local objects on NetBSD (authored by mgorny, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D56000?vs=179414&id=179443#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56000/new/

https://reviews.llvm.org/D56000

Files:
  compiler-rt/trunk/lib/xray/xray_basic_logging.cc
  compiler-rt/trunk/lib/xray/xray_defs.h
  compiler-rt/trunk/lib/xray/xray_fdr_logging.cc


Index: compiler-rt/trunk/lib/xray/xray_basic_logging.cc
===================================================================
--- compiler-rt/trunk/lib/xray/xray_basic_logging.cc
+++ compiler-rt/trunk/lib/xray/xray_basic_logging.cc
@@ -55,7 +55,7 @@
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
 
-struct alignas(64) ThreadLocalData {
+struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
   void *InMemoryBuffer = nullptr;
   size_t BufferSize = 0;
   size_t BufferOffset = 0;
Index: compiler-rt/trunk/lib/xray/xray_defs.h
===================================================================
--- compiler-rt/trunk/lib/xray/xray_defs.h
+++ compiler-rt/trunk/lib/xray/xray_defs.h
@@ -19,4 +19,14 @@
 #define XRAY_NEVER_INSTRUMENT
 #endif
 
+#if SANITIZER_NETBSD
+// NetBSD: thread_local is not aligned properly, and the code relying
+// on it segfaults
+#define XRAY_TLS_ALIGNAS(x)
+#define XRAY_HAS_TLS_ALIGNAS 0
+#else
+#define XRAY_TLS_ALIGNAS(x) alignas(x)
+#define XRAY_HAS_TLS_ALIGNAS 1
+#endif
+
 #endif  // XRAY_XRAY_DEFS_H
Index: compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
===================================================================
--- compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
+++ compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
@@ -51,7 +51,7 @@
 // call so that it can be initialized on first use instead of as a global. We
 // force the alignment to 64-bytes for x86 cache line alignment, as this
 // structure is used in the hot path of implementation.
-struct alignas(64) ThreadLocalData {
+struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
   BufferQueue::Buffer Buffer{};
   BufferQueue *BQ = nullptr;
 
@@ -124,8 +124,10 @@
 // critical section, calling a function that might be XRay instrumented (and
 // thus in turn calling into malloc by virtue of registration of the
 // thread_local's destructor).
+#if XRAY_HAS_TLS_ALIGNAS
 static_assert(alignof(ThreadLocalData) >= 64,
               "ThreadLocalData must be cache line aligned.");
+#endif
 static ThreadLocalData &getThreadLocalData() {
   thread_local typename std::aligned_storage<
       sizeof(ThreadLocalData), alignof(ThreadLocalData)>::type TLDStorage{};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56000.179443.patch
Type: text/x-patch
Size: 2169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181223/1b143a35/attachment.bin>


More information about the cfe-commits mailing list