From 92858528c2db534e4101b7ac6cd263ac7884764d Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Tue, 22 Jul 2025 18:50:45 -0700 Subject: [clang][timers][stats] Add a flag to enable timers in the stats file (#149946) As reported in #138173, enabling `-ftime-report` adds pass timing info to the stats file if `-stats-file` is specified. This was determined to be WAI. However, if one intentionally wants to put timer information in the stats file, using `-ftime-report` may lead to a lot of logspam (that can't be removed by directing stderr to `/dev/null` as that would also redirect compiler errors). To address this, this PR adds a flag `-stats-file-timers` that adds timer data to the stats file without outputting to stderr. --- clang/lib/Frontend/CompilerInvocation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 3a36250..ab4384a 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2013,8 +2013,8 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, : llvm::codegenoptions::DebugTemplateNamesKind::Mangled); } - if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ, - OPT_ftime_report_json)) { + if (Args.hasArg(OPT_ftime_report, OPT_ftime_report_EQ, OPT_ftime_report_json, + OPT_stats_file_timers)) { Opts.TimePasses = true; // -ftime-report= is only for new pass manager. @@ -2026,7 +2026,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Opts.TimePassesPerRun = true; else Diags.Report(diag::err_drv_invalid_value) - << A->getAsString(Args) << A->getValue(); + << EQ->getAsString(Args) << EQ->getValue(); } if (Args.getLastArg(OPT_ftime_report_json)) -- cgit v1.1