diff options
Diffstat (limited to 'llvm/lib/Support/TimeProfiler.cpp')
-rw-r--r-- | llvm/lib/Support/TimeProfiler.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp index c37c74c..8f2544e 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 std::vector<TimeTraceProfiler *> +static ManagedStatic<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; } |