Author: Fangrui Song Date: 2025-01-12T13:17:49-08:00 New Revision: 5c0aa31c3cb448065f12ede53e4dd54a9a98f650
URL: https://github.com/llvm/llvm-project/commit/5c0aa31c3cb448065f12ede53e4dd54a9a98f650 DIFF: https://github.com/llvm/llvm-project/commit/5c0aa31c3cb448065f12ede53e4dd54a9a98f650.diff LOG: -ftime-report: Move FrontendTimer closer to TimeTraceScope ... to improve consistency and make "Clang time report" cover `FrontendAction::BeginSourceFile` and `FrontendAction::EndSourceFile`. Added: Modified: clang/include/clang/Frontend/CompilerInstance.h clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/FrontendAction.cpp clang/tools/driver/cc1_main.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index 4a79b8d107171a..8b539dfc92960e 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -632,8 +632,6 @@ class CompilerInstance : public ModuleLoader { llvm::TimerGroup &getTimerGroup() const { return *timerGroup; } - bool hasFrontendTimer() const { return (bool)FrontendTimer; } - llvm::Timer &getFrontendTimer() const { assert(FrontendTimer && "Compiler instance has no frontend timer!"); return *FrontendTimer; diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index b00a4ac0757763..c11c857ea06061 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1038,9 +1038,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { << LLVM_VERSION_STRING << " default target " << llvm::sys::getDefaultTargetTriple() << "\n"; - if (getCodeGenOpts().TimePasses) - createFrontendTimer(); - if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty()) llvm::EnableStatistics(false); diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 9a50e7453eb61a..9f789f093f55dc 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -1069,12 +1069,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, llvm::Error FrontendAction::Execute() { CompilerInstance &CI = getCompilerInstance(); - - if (CI.hasFrontendTimer()) { - llvm::TimeRegion Timer(CI.getFrontendTimer()); - ExecuteAction(); - } - else ExecuteAction(); + ExecuteAction(); // If we are supposed to rebuild the global module index, do so now unless // there were any module-build failures. diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp index d14058ff2c723d..26b5e78cfb4b58 100644 --- a/clang/tools/driver/cc1_main.cpp +++ b/clang/tools/driver/cc1_main.cpp @@ -283,6 +283,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { // Execute the frontend actions. { llvm::TimeTraceScope TimeScope("ExecuteCompiler"); + bool TimePasses = Clang->getCodeGenOpts().TimePasses; + if (TimePasses) + Clang->createFrontendTimer(); + llvm::TimeRegion Timer(TimePasses ? &Clang->getFrontendTimer() : nullptr); Success = ExecuteCompilerInvocation(Clang.get()); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits