[PATCH] D52639: [XRay] Guard local variables with `static` and struct with unnamed namespaces
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 27 18:03:25 PDT 2018
MaskRay created this revision.
MaskRay added reviewers: dberris, mboerger, eizan.
Herald added subscribers: Sanitizers, llvm-commits, jfb, delcypher.
This is for coding standard conformance, and for fixing an ODR violation
issue: __xray::ThreadLocalData is defined twice and differently in
xray_fdr_logging.cc and xray_basic_logging.cc
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D52639
Files:
lib/xray/xray_basic_logging.cc
lib/xray/xray_fdr_logging.cc
Index: lib/xray/xray_fdr_logging.cc
===================================================================
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -42,8 +42,10 @@
namespace __xray {
-atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED};
+static atomic_sint32_t LoggingStatus = {
+ XRayLogInitStatus::XRAY_LOG_UNINITIALIZED};
+namespace {
// Group together thread-local-data in a struct, then hide it behind a function
// 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
@@ -72,6 +74,7 @@
// FDRLogging, and that we're going to clean it up when the thread exits.
BufferQueue *BQ = nullptr;
};
+} // namespace
static_assert(std::is_trivially_destructible<ThreadLocalData>::value,
"ThreadLocalData must be trivially destructible");
Index: lib/xray/xray_basic_logging.cc
===================================================================
--- lib/xray/xray_basic_logging.cc
+++ lib/xray/xray_basic_logging.cc
@@ -38,8 +38,9 @@
namespace __xray {
-SpinMutex LogMutex;
+static SpinMutex LogMutex;
+namespace {
// We use elements of this type to record the entry TSC of every function ID we
// see as we're tracing a particular thread's execution.
struct alignas(16) StackEntry {
@@ -61,6 +62,7 @@
size_t StackEntries = 0;
int Fd = -1;
};
+} // namespace
static pthread_key_t PThreadKey;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52639.167420.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180928/adc7dd39/attachment.bin>
More information about the llvm-commits
mailing list