41
41
#include " llvm/Support/Process.h"
42
42
#include " llvm/Support/Signals.h"
43
43
#include " llvm/Support/ThreadPool.h"
44
- #include " llvm/Support/TimeProfiler.h"
45
44
#include " llvm/Support/raw_ostream.h"
46
45
#include < atomic>
47
46
#include < mutex>
@@ -100,11 +99,6 @@ URL of repository that hosts code.
100
99
Used for links to definition locations.)" ),
101
100
llvm::cl::cat(ClangDocCategory));
102
101
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
-
108
102
enum OutputFormatTy {
109
103
md,
110
104
yaml,
@@ -235,12 +229,6 @@ Example usage for a project using a compile commands database:
235
229
return 1 ;
236
230
}
237
231
238
- // turns on ftime trace profiling
239
- if (FTimeTrace)
240
- llvm::timeTraceProfilerInitialize (200 , " clang-doc" );
241
-
242
- llvm::TimeTraceScope (" main" );
243
-
244
232
// Fail early if an invalid format was provided.
245
233
std::string Format = getFormatString ();
246
234
llvm::outs () << " Emiting docs in " << Format << " format.\n " ;
@@ -264,8 +252,8 @@ Example usage for a project using a compile commands database:
264
252
OutDirectory,
265
253
SourceRoot,
266
254
RepositoryUrl,
267
- {UserStylesheets.begin (), UserStylesheets.end ()},
268
- FTimeTrace };
255
+ {UserStylesheets.begin (), UserStylesheets.end ()}
256
+ };
269
257
270
258
if (Format == " html" ) {
271
259
if (auto Err = getHtmlAssetFiles (argv[0 ], CDCtx)) {
@@ -274,7 +262,6 @@ Example usage for a project using a compile commands database:
274
262
}
275
263
}
276
264
277
- llvm::timeTraceProfilerBegin (" Mapping declaration" , " total runtime" );
278
265
// Mapping phase
279
266
llvm::outs () << " Mapping decls...\n " ;
280
267
auto Err =
@@ -289,28 +276,24 @@ Example usage for a project using a compile commands database:
289
276
return 1 ;
290
277
}
291
278
}
292
- llvm::timeTraceProfilerEnd ();
293
279
294
280
// Collect values into output by key.
295
281
// In ToolResults, the Key is the hashed USR and the value is the
296
282
// bitcode-encoded representation of the Info object.
297
- llvm::timeTraceProfilerBegin (" Collect Info" , " total runtime" );
298
283
llvm::outs () << " Collecting infos...\n " ;
299
284
llvm::StringMap<std::vector<StringRef>> USRToBitcode;
300
285
Executor->get ()->getToolResults ()->forEachResult (
301
286
[&](StringRef Key, StringRef Value) {
302
287
auto R = USRToBitcode.try_emplace (Key, std::vector<StringRef>());
303
288
R.first ->second .emplace_back (Value);
304
289
});
305
- llvm::timeTraceProfilerEnd ();
306
290
307
291
// Collects all Infos according to their unique USR value. This map is added
308
292
// to from the thread pool below and is protected by the USRToInfoMutex.
309
293
llvm::sys::Mutex USRToInfoMutex;
310
294
llvm::StringMap<std::unique_ptr<doc::Info>> USRToInfo;
311
295
312
296
// First reducing phase (reduce all decls into one info per decl).
313
- llvm::timeTraceProfilerBegin (" Reducing infos" , " total runtime" );
314
297
llvm::outs () << " Reducing " << USRToBitcode.size () << " infos...\n " ;
315
298
std::atomic<bool > Error;
316
299
Error = false ;
@@ -319,11 +302,8 @@ Example usage for a project using a compile commands database:
319
302
llvm::DefaultThreadPool Pool (llvm::hardware_concurrency (ExecutorConcurrency));
320
303
for (auto &Group : USRToBitcode) {
321
304
Pool.async ([&]() {
322
- if (FTimeTrace)
323
- llvm::timeTraceProfilerInitialize (200 , " clang-doc" );
324
-
325
- llvm::timeTraceProfilerBegin (" Reducing infos" , " decoding bitcode" );
326
305
std::vector<std::unique_ptr<doc::Info>> Infos;
306
+
327
307
for (auto &Bitcode : Group.getValue ()) {
328
308
llvm::BitstreamCursor Stream (Bitcode);
329
309
doc::ClangDocBitcodeReader Reader (Stream);
@@ -336,40 +316,32 @@ Example usage for a project using a compile commands database:
336
316
std::move (ReadInfos->begin (), ReadInfos->end (),
337
317
std::back_inserter (Infos));
338
318
}
339
- llvm::timeTraceProfilerEnd ();
340
319
341
- llvm::timeTraceProfilerBegin (" Reducing infos" , " merging bitcode" );
342
320
auto Reduced = doc::mergeInfos (Infos);
343
321
if (!Reduced) {
344
322
llvm::errs () << llvm::toString (Reduced.takeError ());
345
323
return ;
346
324
}
347
- llvm::timeTraceProfilerEnd ();
348
325
349
326
// Add a reference to this Info in the Index
350
327
{
351
328
std::lock_guard<llvm::sys::Mutex> Guard (IndexMutex);
352
329
clang::doc::Generator::addInfoToIndex (CDCtx.Idx , Reduced.get ().get ());
353
330
}
354
- // Save in the result map (needs a lock due to threaded access).
355
331
332
+ // Save in the result map (needs a lock due to threaded access).
356
333
{
357
334
std::lock_guard<llvm::sys::Mutex> Guard (USRToInfoMutex);
358
335
USRToInfo[Group.getKey ()] = std::move (Reduced.get ());
359
336
}
360
-
361
- if (CDCtx.FTimeTrace )
362
- llvm::timeTraceProfilerFinishThread ();
363
337
});
364
338
}
365
- llvm::timeTraceProfilerEnd ();
366
339
367
340
Pool.wait ();
368
341
369
342
if (Error)
370
343
return 1 ;
371
344
372
- llvm::timeTraceProfilerBegin (" Writing output" , " total runtime" );
373
345
// Ensure the root output directory exists.
374
346
if (std::error_code Err = llvm::sys::fs::create_directories (OutDirectory);
375
347
Err != std::error_code ()) {
@@ -390,16 +362,6 @@ Example usage for a project using a compile commands database:
390
362
if (Err) {
391
363
llvm::outs () << " warning: " << toString (std::move (Err)) << " \n " ;
392
364
}
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
+
404
366
return 0 ;
405
367
}
0 commit comments