aboutsummaryrefslogtreecommitdiffstats
path: root/tools/driver/cc1_main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/driver/cc1_main.cpp')
-rw-r--r--tools/driver/cc1_main.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp
index 7315a1357089..9e4f32da884f 100644
--- a/tools/driver/cc1_main.cpp
+++ b/tools/driver/cc1_main.cpp
@@ -194,8 +194,8 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// Register the support for object-file-wrapped Clang modules.
auto PCHOps = Clang->getPCHContainerOperations();
- PCHOps->registerWriter(llvm::make_unique<ObjectFilePCHContainerWriter>());
- PCHOps->registerReader(llvm::make_unique<ObjectFilePCHContainerReader>());
+ PCHOps->registerWriter(std::make_unique<ObjectFilePCHContainerWriter>());
+ PCHOps->registerReader(std::make_unique<ObjectFilePCHContainerReader>());
// Initialize targets first, so that --version shows registered targets.
llvm::InitializeAllTargets();
@@ -213,12 +213,13 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
- bool Success = CompilerInvocation::CreateFromArgs(
- Clang->getInvocation(), Argv.begin(), Argv.end(), Diags);
-
- if (Clang->getFrontendOpts().TimeTrace)
- llvm::timeTraceProfilerInitialize();
+ bool Success =
+ CompilerInvocation::CreateFromArgs(Clang->getInvocation(), Argv, Diags);
+ if (Clang->getFrontendOpts().TimeTrace) {
+ llvm::timeTraceProfilerInitialize(
+ Clang->getFrontendOpts().TimeTraceGranularity);
+ }
// --print-supported-cpus takes priority over the actual compilation.
if (Clang->getFrontendOpts().PrintSupportedCPUs)
return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
@@ -252,26 +253,23 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// If any timers were active but haven't been destroyed yet, print their
// results now. This happens in -disable-free mode.
llvm::TimerGroup::printAll(llvm::errs());
+ llvm::TimerGroup::clearAll();
if (llvm::timeTraceProfilerEnabled()) {
SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
llvm::sys::path::replace_extension(Path, "json");
- auto profilerOutput =
- Clang->createOutputFile(Path.str(),
- /*Binary=*/false,
- /*RemoveFileOnSignal=*/false, "",
- /*Extension=*/"json",
- /*useTemporary=*/false);
-
- llvm::timeTraceProfilerWrite(*profilerOutput);
- // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
- profilerOutput->flush();
- llvm::timeTraceProfilerCleanup();
-
- llvm::errs() << "Time trace json-file dumped to " << Path.str() << "\n";
- llvm::errs()
- << "Use chrome://tracing or Speedscope App "
- "(https://www.speedscope.app) for flamegraph visualization\n";
+ if (auto profilerOutput =
+ Clang->createOutputFile(Path.str(),
+ /*Binary=*/false,
+ /*RemoveFileOnSignal=*/false, "",
+ /*Extension=*/"json",
+ /*useTemporary=*/false)) {
+
+ llvm::timeTraceProfilerWrite(*profilerOutput);
+ // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
+ profilerOutput->flush();
+ llvm::timeTraceProfilerCleanup();
+ }
}
// Our error handler depends on the Diagnostics object, which we're