4141#include " llvm/Support/Process.h"
4242#include " llvm/Support/Signals.h"
4343#include " llvm/Support/ThreadPool.h"
44- #include " llvm/Support/TimeProfiler.h"
4544#include " llvm/Support/raw_ostream.h"
4645#include < atomic>
4746#include < mutex>
@@ -100,11 +99,6 @@ URL of repository that hosts code.
10099Used for links to definition locations.)" ),
101100 llvm::cl::cat(ClangDocCategory));
102101
103- static llvm::cl::opt<bool > FTimeTrace (" ftime-trace" , llvm::cl::desc(R"(
104- Turn on time profiler. Generates clang-doc-tracing.json)" ),
105- llvm::cl::init(false ),
106- llvm::cl::cat(ClangDocCategory));
107-
108102enum OutputFormatTy {
109103 md,
110104 yaml,
@@ -235,12 +229,6 @@ Example usage for a project using a compile commands database:
235229 return 1 ;
236230 }
237231
238- // turns on ftime trace profiling
239- if (FTimeTrace)
240- llvm::timeTraceProfilerInitialize (200 , " clang-doc" );
241-
242- llvm::TimeTraceScope (" main" );
243-
244232 // Fail early if an invalid format was provided.
245233 std::string Format = getFormatString ();
246234 llvm::outs () << " Emiting docs in " << Format << " format.\n " ;
@@ -264,8 +252,8 @@ Example usage for a project using a compile commands database:
264252 OutDirectory,
265253 SourceRoot,
266254 RepositoryUrl,
267- {UserStylesheets.begin (), UserStylesheets.end ()},
268- FTimeTrace };
255+ {UserStylesheets.begin (), UserStylesheets.end ()}
256+ };
269257
270258 if (Format == " html" ) {
271259 if (auto Err = getHtmlAssetFiles (argv[0 ], CDCtx)) {
@@ -274,7 +262,6 @@ Example usage for a project using a compile commands database:
274262 }
275263 }
276264
277- llvm::timeTraceProfilerBegin (" Mapping declaration" , " total runtime" );
278265 // Mapping phase
279266 llvm::outs () << " Mapping decls...\n " ;
280267 auto Err =
@@ -289,28 +276,24 @@ Example usage for a project using a compile commands database:
289276 return 1 ;
290277 }
291278 }
292- llvm::timeTraceProfilerEnd ();
293279
294280 // Collect values into output by key.
295281 // In ToolResults, the Key is the hashed USR and the value is the
296282 // bitcode-encoded representation of the Info object.
297- llvm::timeTraceProfilerBegin (" Collect Info" , " total runtime" );
298283 llvm::outs () << " Collecting infos...\n " ;
299284 llvm::StringMap<std::vector<StringRef>> USRToBitcode;
300285 Executor->get ()->getToolResults ()->forEachResult (
301286 [&](StringRef Key, StringRef Value) {
302287 auto R = USRToBitcode.try_emplace (Key, std::vector<StringRef>());
303288 R.first ->second .emplace_back (Value);
304289 });
305- llvm::timeTraceProfilerEnd ();
306290
307291 // Collects all Infos according to their unique USR value. This map is added
308292 // to from the thread pool below and is protected by the USRToInfoMutex.
309293 llvm::sys::Mutex USRToInfoMutex;
310294 llvm::StringMap<std::unique_ptr<doc::Info>> USRToInfo;
311295
312296 // First reducing phase (reduce all decls into one info per decl).
313- llvm::timeTraceProfilerBegin (" Reducing infos" , " total runtime" );
314297 llvm::outs () << " Reducing " << USRToBitcode.size () << " infos...\n " ;
315298 std::atomic<bool > Error;
316299 Error = false ;
@@ -319,11 +302,8 @@ Example usage for a project using a compile commands database:
319302 llvm::DefaultThreadPool Pool (llvm::hardware_concurrency (ExecutorConcurrency));
320303 for (auto &Group : USRToBitcode) {
321304 Pool.async ([&]() {
322- if (FTimeTrace)
323- llvm::timeTraceProfilerInitialize (200 , " clang-doc" );
324-
325- llvm::timeTraceProfilerBegin (" Reducing infos" , " decoding bitcode" );
326305 std::vector<std::unique_ptr<doc::Info>> Infos;
306+
327307 for (auto &Bitcode : Group.getValue ()) {
328308 llvm::BitstreamCursor Stream (Bitcode);
329309 doc::ClangDocBitcodeReader Reader (Stream);
@@ -336,40 +316,32 @@ Example usage for a project using a compile commands database:
336316 std::move (ReadInfos->begin (), ReadInfos->end (),
337317 std::back_inserter (Infos));
338318 }
339- llvm::timeTraceProfilerEnd ();
340319
341- llvm::timeTraceProfilerBegin (" Reducing infos" , " merging bitcode" );
342320 auto Reduced = doc::mergeInfos (Infos);
343321 if (!Reduced) {
344322 llvm::errs () << llvm::toString (Reduced.takeError ());
345323 return ;
346324 }
347- llvm::timeTraceProfilerEnd ();
348325
349326 // Add a reference to this Info in the Index
350327 {
351328 std::lock_guard<llvm::sys::Mutex> Guard (IndexMutex);
352329 clang::doc::Generator::addInfoToIndex (CDCtx.Idx , Reduced.get ().get ());
353330 }
354- // Save in the result map (needs a lock due to threaded access).
355331
332+ // Save in the result map (needs a lock due to threaded access).
356333 {
357334 std::lock_guard<llvm::sys::Mutex> Guard (USRToInfoMutex);
358335 USRToInfo[Group.getKey ()] = std::move (Reduced.get ());
359336 }
360-
361- if (CDCtx.FTimeTrace )
362- llvm::timeTraceProfilerFinishThread ();
363337 });
364338 }
365- llvm::timeTraceProfilerEnd ();
366339
367340 Pool.wait ();
368341
369342 if (Error)
370343 return 1 ;
371344
372- llvm::timeTraceProfilerBegin (" Writing output" , " total runtime" );
373345 // Ensure the root output directory exists.
374346 if (std::error_code Err = llvm::sys::fs::create_directories (OutDirectory);
375347 Err != std::error_code ()) {
@@ -390,16 +362,6 @@ Example usage for a project using a compile commands database:
390362 if (Err) {
391363 llvm::outs () << " warning: " << toString (std::move (Err)) << " \n " ;
392364 }
393- llvm::timeTraceProfilerEnd ();
394-
395- if (FTimeTrace) {
396- std::error_code EC;
397- llvm::raw_fd_ostream OS (" clang-doc-tracing.json" , EC,
398- llvm::sys::fs::OF_Text);
399- if (!EC)
400- llvm::timeTraceProfilerWrite (OS);
401- else
402- return 1 ;
403- }
365+
404366 return 0 ;
405367}
0 commit comments