aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/TimeProfiler.cpp
diff options
context:
space:
mode:
authorMehdi Amini <joker.eph@gmail.com>2021-07-16 07:34:41 +0000
committerMehdi Amini <joker.eph@gmail.com>2021-07-16 07:35:13 +0000
commit8d051d854619956de633047409149cdab1e3319a (patch)
treee51ddd9e2fdb3237526b74ab09484bec6b4ca44a /llvm/lib/Support/TimeProfiler.cpp
parent3d3dc9523f9b2ec9d83d37bd8a757726f37b6ee5 (diff)
downloadllvm-8d051d854619956de633047409149cdab1e3319a.zip
llvm-8d051d854619956de633047409149cdab1e3319a.tar.gz
llvm-8d051d854619956de633047409149cdab1e3319a.tar.bz2
Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer"
This reverts commit af9321739b20becf170e6bb5060b8d780e1dc8dd. Still some specific config broken in some way that requires more investigation.
Diffstat (limited to 'llvm/lib/Support/TimeProfiler.cpp')
-rw-r--r--llvm/lib/Support/TimeProfiler.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp
index 8f2544e..c37c74c 100644
--- a/llvm/lib/Support/TimeProfiler.cpp
+++ b/llvm/lib/Support/TimeProfiler.cpp
@@ -30,7 +30,7 @@ using namespace llvm;
static std::mutex Mu;
// List of all instances
-static ManagedStatic<std::vector<TimeTraceProfiler *>>
+static std::vector<TimeTraceProfiler *>
ThreadTimeTraceProfilerInstances; // GUARDED_BY(Mu)
// Per Thread instance
static LLVM_THREAD_LOCAL TimeTraceProfiler *TimeTraceProfilerInstance = nullptr;
@@ -128,7 +128,7 @@ struct llvm::TimeTraceProfiler {
std::lock_guard<std::mutex> Lock(Mu);
assert(Stack.empty() &&
"All profiler sections should be ended when calling write");
- assert(llvm::all_of(*ThreadTimeTraceProfilerInstances,
+ assert(llvm::all_of(ThreadTimeTraceProfilerInstances,
[](const auto &TTP) { return TTP->Stack.empty(); }) &&
"All profiler sections should be ended when calling write");
@@ -156,7 +156,7 @@ struct llvm::TimeTraceProfiler {
};
for (const Entry &E : Entries)
writeEvent(E, this->Tid);
- for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
+ for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
for (const Entry &E : TTP->Entries)
writeEvent(E, TTP->Tid);
@@ -164,7 +164,7 @@ struct llvm::TimeTraceProfiler {
// longest one.
// Find highest used thread id.
uint64_t MaxTid = this->Tid;
- for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
+ for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
MaxTid = std::max(MaxTid, TTP->Tid);
// Combine all CountAndTotalPerName from threads into one.
@@ -178,7 +178,7 @@ struct llvm::TimeTraceProfiler {
};
for (const auto &Stat : CountAndTotalPerName)
combineStat(Stat);
- for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
+ for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
for (const auto &Stat : TTP->CountAndTotalPerName)
combineStat(Stat);
@@ -229,7 +229,7 @@ struct llvm::TimeTraceProfiler {
writeMetadataEvent("process_name", Tid, ProcName);
writeMetadataEvent("thread_name", Tid, ThreadName);
- for (const TimeTraceProfiler *TTP : *ThreadTimeTraceProfilerInstances)
+ for (const TimeTraceProfiler *TTP : ThreadTimeTraceProfilerInstances)
writeMetadataEvent("thread_name", TTP->Tid, TTP->ThreadName);
J.arrayEnd();
@@ -273,16 +273,16 @@ void llvm::timeTraceProfilerInitialize(unsigned TimeTraceGranularity,
void llvm::timeTraceProfilerCleanup() {
delete TimeTraceProfilerInstance;
std::lock_guard<std::mutex> Lock(Mu);
- for (auto TTP : *ThreadTimeTraceProfilerInstances)
+ for (auto TTP : ThreadTimeTraceProfilerInstances)
delete TTP;
- ThreadTimeTraceProfilerInstances->clear();
+ ThreadTimeTraceProfilerInstances.clear();
}
// Finish TimeTraceProfilerInstance on a worker thread.
// This doesn't remove the instance, just moves the pointer to global vector.
void llvm::timeTraceProfilerFinishThread() {
std::lock_guard<std::mutex> Lock(Mu);
- ThreadTimeTraceProfilerInstances->push_back(TimeTraceProfilerInstance);
+ ThreadTimeTraceProfilerInstances.push_back(TimeTraceProfilerInstance);
TimeTraceProfilerInstance = nullptr;
}