@@ -94,13 +94,17 @@ struct TimeTraceMetadata {
9494 bool isEmpty () const { return Detail.empty () && File.empty (); }
9595};
9696
97+ struct TimeTraceProfilerEntry ;
98+ struct InstantEvent ;
99+ struct DurableEvent ;
100+ struct CompleteEvent ;
101+ struct AsyncEvent ;
102+
97103struct TimeTraceProfiler ;
98104TimeTraceProfiler *getTimeTraceProfilerInstance ();
99105
100106bool isTimeTraceVerbose ();
101107
102- struct TimeTraceProfilerEntry ;
103-
104108// / Initialize the time trace profiler.
105109// / This sets up the global \p TimeTraceProfilerInstance
106110// / variable to be the profiler instance.
@@ -136,13 +140,13 @@ Error timeTraceProfilerWrite(StringRef PreferredFileName,
136140// / Profiler copies the string data, so the pointers can be given into
137141// / temporaries. Time sections can be hierarchical; every Begin must have a
138142// / matching End pair but they can nest.
139- TimeTraceProfilerEntry * timeTraceProfilerBegin (StringRef Name,
140- StringRef Detail);
141- TimeTraceProfilerEntry *
143+ std::shared_ptr<DurableEvent> timeTraceProfilerBegin (StringRef Name,
144+ StringRef Detail);
145+ std::shared_ptr<DurableEvent>
142146timeTraceProfilerBegin (StringRef Name,
143147 llvm::function_ref<std::string()> Detail);
144148
145- TimeTraceProfilerEntry *
149+ std::shared_ptr<DurableEvent>
146150timeTraceProfilerBegin (StringRef Name,
147151 llvm::function_ref<TimeTraceMetadata()> MetaData);
148152
@@ -151,16 +155,17 @@ timeTraceProfilerBegin(StringRef Name,
151155// / separately from other traces. See
152156// / https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
153157// / for more details.
154- TimeTraceProfilerEntry * timeTraceAsyncProfilerBegin (StringRef Name,
155- StringRef Detail);
158+ std::shared_ptr<DurableEvent> timeTraceAsyncProfilerBegin (StringRef Name,
159+ StringRef Detail);
156160
157161// Mark an instant event.
158- TimeTraceProfilerEntry * timeTraceInstantEventProfilerBegin (StringRef Name,
162+ void timeTraceProfilerInsert (StringRef Name,
159163 llvm::function_ref<TimeTraceMetadata()> Metadata);
164+ void timeTraceProfilerInsert (StringRef Name, StringRef Detail);
160165
161166// / Manually end the last time section.
162167void timeTraceProfilerEnd ();
163- void timeTraceProfilerEnd (TimeTraceProfilerEntry * E);
168+ void timeTraceProfilerEnd (std::shared_ptr<DurableEvent> & E);
164169
165170// / The TimeTraceScope is a helper class to call the begin and end functions
166171// / of the time trace profiler. When the object is constructed, it begins
@@ -187,26 +192,17 @@ class TimeTraceScope {
187192 Entry = timeTraceProfilerBegin (Name, Detail);
188193 }
189194 TimeTraceScope (StringRef Name,
190- llvm::function_ref<TimeTraceMetadata()> Metadata, TimeTraceEventType Et = TimeTraceEventType::CompleteEvent) {
191- if (getTimeTraceProfilerInstance () == nullptr )
192- return ;
193- assert ((Et == TimeTraceEventType::InstantEvent ||
194- Et == TimeTraceEventType::CompleteEvent) &&
195- " Event Type not supported." );
196-
197- if (Et == TimeTraceEventType::CompleteEvent) {
195+ llvm::function_ref<TimeTraceMetadata()> Metadata) {
196+ if (getTimeTraceProfilerInstance () != nullptr )
198197 Entry = timeTraceProfilerBegin (Name, Metadata);
199- } else {
200- Entry = timeTraceInstantEventProfilerBegin (Name, Metadata);
201- }
202198 }
203199 ~TimeTraceScope () {
204200 if (getTimeTraceProfilerInstance () != nullptr )
205201 timeTraceProfilerEnd (Entry);
206202 }
207203
208204private:
209- TimeTraceProfilerEntry * Entry = nullptr ;
205+ std::shared_ptr<DurableEvent> Entry = nullptr ;
210206};
211207
212208} // end namespace llvm
0 commit comments