[clang] -ftime-report: reorganize timers (PR #122225)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 09:55:53 PST 2025
================
@@ -1346,14 +1344,30 @@ static void runThinLTOBackend(
}
}
-void clang::EmitBackendOutput(
- DiagnosticsEngine &Diags, const HeaderSearchOptions &HeaderOpts,
- const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts,
- const LangOptions &LOpts, StringRef TDesc, llvm::Module *M,
- BackendAction Action, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
- std::unique_ptr<raw_pwrite_stream> OS, BackendConsumer *BC) {
-
+void clang::emitBackendOutput(CompilerInstance &CI, StringRef TDesc,
+ llvm::Module *M, BackendAction Action,
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
+ std::unique_ptr<raw_pwrite_stream> OS,
+ BackendConsumer *BC) {
llvm::TimeTraceScope TimeScope("Backend");
+ DiagnosticsEngine &Diags = CI.getDiagnostics();
+ const auto &HeaderOpts = CI.getHeaderSearchOpts();
+ const auto &CGOpts = CI.getCodeGenOpts();
+ const auto &TOpts = CI.getTargetOpts();
+ const auto &LOpts = CI.getLangOpts();
+
+ Timer timer;
+ if (CGOpts.TimePasses) {
+ CI.getFrontendTimer().stopTimer();
+ timer.init("backend", "Backend", CI.getTimerGroup());
+ timer.startTimer();
+ }
+ auto _ = llvm::make_scope_exit([&] {
----------------
MaskRay wrote:
`emitBackendOutput` is a subset of clang/lib/Frontend/FrontendAction.cpp:1074 `llvm::TimeRegion Timer(CI.getFrontendTimer())`. We have to start `getFrontendTimer()` after `Backend` stops (required by `TimeRegion`).
Since we both stop a timer and start a timer, I resort to a make_scope_exit.
https://github.com/llvm/llvm-project/pull/122225
More information about the cfe-commits
mailing list