aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-01-10 19:25:18 -0800
committerGitHub <noreply@github.com>2025-01-10 19:25:18 -0800
commit0de18e72c607c1b52be2c60d45cf2f9fc3af4542 (patch)
tree573b0ec23d72e7765236a997d963ebe797a2c8ef /clang/lib/Frontend/CompilerInstance.cpp
parentdf808df8f73e30d288e4dfdef5e527bc392f3bce (diff)
downloadllvm-0de18e72c607c1b52be2c60d45cf2f9fc3af4542.zip
llvm-0de18e72c607c1b52be2c60d45cf2f9fc3af4542.tar.gz
llvm-0de18e72c607c1b52be2c60d45cf2f9fc3af4542.tar.bz2
-ftime-report: reorganize timers
The code generation time is unclear in the -ftime-report output: * The two clang timers "Code Generation Time" and "LLVM IR Generation Time" are in the default group "Miscellaneous Ungrouped Timers". * There is also a "Clang front-end time" group, which actually includes code generation time. ``` ===-------------------------------------------------------------------------=== Miscellaneous Ungrouped Timers ===-------------------------------------------------------------------------=== ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.0611 ( 1.7%) 0.0099 ( 4.4%) 0.0710 ( 1.9%) 0.0713 ( 1.9%) LLVM IR Generation Time 3.5140 ( 98.3%) 0.2165 ( 95.6%) 3.7306 ( 98.1%) 3.7342 ( 98.1%) Code Generation Time 3.5751 (100.0%) 0.2265 (100.0%) 3.8016 (100.0%) 3.8055 (100.0%) Total ... ===-------------------------------------------------------------------------=== Clang front-end time report ===-------------------------------------------------------------------------=== Total Execution Time: 3.9108 seconds (3.9146 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 3.6802 (100.0%) 0.2306 (100.0%) 3.9108 (100.0%) 3.9146 (100.0%) Clang front-end timer 3.6802 (100.0%) 0.2306 (100.0%) 3.9108 (100.0%) 3.9146 (100.0%) Total ``` This patch * renames "Clang front-end time report" (FrontendAction time) to "Clang time report", * renames "Clang front-end" to "Front end", * moves "LLVM IR Generation" into the group, * replaces "Code Generation time" with "Optimizer" (middle end) and "Machine code generation" (back end). ``` % clang -c sqlite3.i -w -ftime-report -mllvm -sort-timers=0 ... ===-------------------------------------------------------------------------=== Clang time report ===-------------------------------------------------------------------------=== Total Execution Time: 1.5922 seconds (1.5972 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.5107 ( 35.9%) 0.0105 ( 6.2%) 0.5211 ( 32.7%) 0.5222 ( 32.7%) Front end 0.2464 ( 17.3%) 0.0340 ( 20.0%) 0.2804 ( 17.6%) 0.2814 ( 17.6%) LLVM IR generation 0.6240 ( 43.9%) 0.1235 ( 72.7%) 0.7475 ( 47.0%) 0.7503 ( 47.0%) Machine code generation 0.0413 ( 2.9%) 0.0018 ( 1.0%) 0.0431 ( 2.7%) 0.0433 ( 2.7%) Optimizer 1.4224 (100.0%) 0.1698 (100.0%) 1.5922 (100.0%) 1.5972 (100.0%) Total ``` Pull Request: https://github.com/llvm/llvm-project/pull/122225
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index fbfc305..b00a4ac 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -722,11 +722,8 @@ void CompilerInstance::createCodeCompletionConsumer() {
}
void CompilerInstance::createFrontendTimer() {
- FrontendTimerGroup.reset(
- new llvm::TimerGroup("frontend", "Clang front-end time report"));
- FrontendTimer.reset(
- new llvm::Timer("frontend", "Clang front-end timer",
- *FrontendTimerGroup));
+ timerGroup.reset(new llvm::TimerGroup("clang", "Clang time report"));
+ FrontendTimer.reset(new llvm::Timer("frontend", "Front end", *timerGroup));
}
CodeCompleteConsumer *
@@ -1726,10 +1723,9 @@ void CompilerInstance::createASTReader() {
const FrontendOptions &FEOpts = getFrontendOpts();
std::unique_ptr<llvm::Timer> ReadTimer;
- if (FrontendTimerGroup)
+ if (timerGroup)
ReadTimer = std::make_unique<llvm::Timer>("reading_modules",
- "Reading modules",
- *FrontendTimerGroup);
+ "Reading modules", *timerGroup);
TheASTReader = new ASTReader(
getPreprocessor(), getModuleCache(), &getASTContext(),
getPCHContainerReader(), getFrontendOpts().ModuleFileExtensions,
@@ -1758,10 +1754,10 @@ void CompilerInstance::createASTReader() {
bool CompilerInstance::loadModuleFile(
StringRef FileName, serialization::ModuleFile *&LoadedModuleFile) {
llvm::Timer Timer;
- if (FrontendTimerGroup)
+ if (timerGroup)
Timer.init("preloading." + FileName.str(), "Preloading " + FileName.str(),
- *FrontendTimerGroup);
- llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr);
+ *timerGroup);
+ llvm::TimeRegion TimeLoading(timerGroup ? &Timer : nullptr);
// If we don't already have an ASTReader, create one now.
if (!TheASTReader)
@@ -1892,10 +1888,10 @@ ModuleLoadResult CompilerInstance::findOrCompileModuleAndReadAST(
// Time how long it takes to load the module.
llvm::Timer Timer;
- if (FrontendTimerGroup)
+ if (timerGroup)
Timer.init("loading." + ModuleFilename, "Loading " + ModuleFilename,
- *FrontendTimerGroup);
- llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr);
+ *timerGroup);
+ llvm::TimeRegion TimeLoading(timerGroup ? &Timer : nullptr);
llvm::TimeTraceScope TimeScope("Module Load", ModuleName);
// Try to load the module file. If we are not trying to load from the