[PATCH] D73639: [LLVM] Wrap extern TLS variable in getter Function
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 01:37:14 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f6a2f1ec520: [Support] Wrap extern TLS variable in getter function (authored by zero9178, committed by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73639/new/
https://reviews.llvm.org/D73639
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
@@ -24,16 +24,22 @@
#include <vector>
using namespace std::chrono;
+using namespace llvm;
namespace {
std::mutex Mu;
-std::vector<llvm::TimeTraceProfiler *>
+// List of all instances
+std::vector<TimeTraceProfiler *>
ThreadTimeTraceProfilerInstances; // guarded by Mu
+// Per Thread instance
+LLVM_THREAD_LOCAL TimeTraceProfiler *TimeTraceProfilerInstance = nullptr;
} // namespace
namespace llvm {
-LLVM_THREAD_LOCAL TimeTraceProfiler *TimeTraceProfilerInstance = nullptr;
+TimeTraceProfiler *getTimeTraceProfilerInstance() {
+ return TimeTraceProfilerInstance;
+}
typedef duration<steady_clock::rep, steady_clock::period> DurationType;
typedef time_point<steady_clock> TimePointType;
Index: llvm/include/llvm/Support/TimeProfiler.h
===================================================================
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -14,7 +14,7 @@
namespace llvm {
struct TimeTraceProfiler;
-extern LLVM_THREAD_LOCAL TimeTraceProfiler *TimeTraceProfilerInstance;
+TimeTraceProfiler *getTimeTraceProfilerInstance();
/// Initialize the time trace profiler.
/// This sets up the global \p TimeTraceProfilerInstance
@@ -30,7 +30,7 @@
/// Is the time trace profiler enabled, i.e. initialized?
inline bool timeTraceProfilerEnabled() {
- return TimeTraceProfilerInstance != nullptr;
+ return getTimeTraceProfilerInstance() != nullptr;
}
/// Write profiling data to output file.
@@ -62,19 +62,19 @@
TimeTraceScope &operator=(TimeTraceScope &&) = delete;
TimeTraceScope(StringRef Name) {
- if (TimeTraceProfilerInstance != nullptr)
+ if (getTimeTraceProfilerInstance() != nullptr)
timeTraceProfilerBegin(Name, StringRef(""));
}
TimeTraceScope(StringRef Name, StringRef Detail) {
- if (TimeTraceProfilerInstance != nullptr)
+ if (getTimeTraceProfilerInstance() != nullptr)
timeTraceProfilerBegin(Name, Detail);
}
TimeTraceScope(StringRef Name, llvm::function_ref<std::string()> Detail) {
- if (TimeTraceProfilerInstance != nullptr)
+ if (getTimeTraceProfilerInstance() != nullptr)
timeTraceProfilerBegin(Name, Detail);
}
~TimeTraceScope() {
- if (TimeTraceProfilerInstance != nullptr)
+ if (getTimeTraceProfilerInstance() != nullptr)
timeTraceProfilerEnd();
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73639.241652.patch
Type: text/x-patch
Size: 2524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200131/866a6d4b/attachment.bin>
More information about the llvm-commits
mailing list