[PATCH] D71548: Fix time trace multi threaded support with LLVM_ENABLE_THREADS=OFF

Russell Gallop via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 04:25:45 PST 2019


russell.gallop updated this revision to Diff 234270.
russell.gallop added a comment.

More specific implementation. Just avoid thread_local when LLVM_ENABLE_THREADS=OFF.


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

https://reviews.llvm.org/D71548

Files:
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp


Index: llvm/lib/Support/TimeProfiler.cpp
===================================================================
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -33,7 +33,7 @@
 
 namespace llvm {
 
-thread_local std::unique_ptr<TimeTraceProfiler> TimeTraceProfilerInstance =
+THREAD_LOCAL_IF_THREADS_ENABLED std::unique_ptr<TimeTraceProfiler> TimeTraceProfilerInstance =
     nullptr;
 
 typedef duration<steady_clock::rep, steady_clock::period> DurationType;
Index: llvm/include/llvm/Support/TimeProfiler.h
===================================================================
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -9,12 +9,19 @@
 #ifndef LLVM_SUPPORT_TIME_PROFILER_H
 #define LLVM_SUPPORT_TIME_PROFILER_H
 
+#include "llvm/Config/llvm-config.h"
 #include "llvm/Support/raw_ostream.h"
 
+#if LLVM_ENABLE_THREADS
+#define THREAD_LOCAL_IF_THREADS_ENABLED thread_local
+#else
+#define THREAD_LOCAL_IF_THREADS_ENABLED
+#endif
+
 namespace llvm {
 
 struct TimeTraceProfiler;
-extern thread_local std::unique_ptr<TimeTraceProfiler>
+extern THREAD_LOCAL_IF_THREADS_ENABLED std::unique_ptr<TimeTraceProfiler>
     TimeTraceProfilerInstance;
 
 /// Initialize the time trace profiler.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71548.234270.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191217/d7a39ebc/attachment.bin>


More information about the llvm-commits mailing list