Skip to content

Commit 5c0aa31

Browse files
committed
-ftime-report: Move FrontendTimer closer to TimeTraceScope
... to improve consistency and make "Clang time report" cover `FrontendAction::BeginSourceFile` and `FrontendAction::EndSourceFile`.
1 parent f5a35a3 commit 5c0aa31

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,6 @@ class CompilerInstance : public ModuleLoader {
632632

633633
llvm::TimerGroup &getTimerGroup() const { return *timerGroup; }
634634

635-
bool hasFrontendTimer() const { return (bool)FrontendTimer; }
636-
637635
llvm::Timer &getFrontendTimer() const {
638636
assert(FrontendTimer && "Compiler instance has no frontend timer!");
639637
return *FrontendTimer;

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
10381038
<< LLVM_VERSION_STRING << " default target "
10391039
<< llvm::sys::getDefaultTargetTriple() << "\n";
10401040

1041-
if (getCodeGenOpts().TimePasses)
1042-
createFrontendTimer();
1043-
10441041
if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
10451042
llvm::EnableStatistics(false);
10461043

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,12 +1069,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
10691069

10701070
llvm::Error FrontendAction::Execute() {
10711071
CompilerInstance &CI = getCompilerInstance();
1072-
1073-
if (CI.hasFrontendTimer()) {
1074-
llvm::TimeRegion Timer(CI.getFrontendTimer());
1075-
ExecuteAction();
1076-
}
1077-
else ExecuteAction();
1072+
ExecuteAction();
10781073

10791074
// If we are supposed to rebuild the global module index, do so now unless
10801075
// there were any module-build failures.

clang/tools/driver/cc1_main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
283283
// Execute the frontend actions.
284284
{
285285
llvm::TimeTraceScope TimeScope("ExecuteCompiler");
286+
bool TimePasses = Clang->getCodeGenOpts().TimePasses;
287+
if (TimePasses)
288+
Clang->createFrontendTimer();
289+
llvm::TimeRegion Timer(TimePasses ? &Clang->getFrontendTimer() : nullptr);
286290
Success = ExecuteCompilerInvocation(Clang.get());
287291
}
288292

0 commit comments

Comments
 (0)