-
Notifications
You must be signed in to change notification settings - Fork 15.3k
-ftime-report: reorganize timers #122225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-ftime-report: reorganize timers #122225
Changes from 4 commits
586f1fa
97fdcb8
dc3ded7
1a32599
d7a856d
41835cb
c9c6310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| #include "clang/Frontend/FrontendDiagnostic.h" | ||
| #include "clang/Frontend/Utils.h" | ||
| #include "clang/Lex/HeaderSearchOptions.h" | ||
| #include "llvm/ADT/ScopeExit.h" | ||
| #include "llvm/ADT/StringExtras.h" | ||
| #include "llvm/ADT/StringSwitch.h" | ||
| #include "llvm/Analysis/GlobalsModRef.h" | ||
|
|
@@ -137,8 +138,6 @@ class EmitAssemblyHelper { | |
| llvm::Module *TheModule; | ||
| IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS; | ||
|
|
||
| Timer CodeGenerationTime; | ||
|
|
||
| std::unique_ptr<raw_pwrite_stream> OS; | ||
|
|
||
| Triple TargetTriple; | ||
|
|
@@ -211,7 +210,6 @@ class EmitAssemblyHelper { | |
| IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) | ||
| : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts), | ||
| TargetOpts(TOpts), LangOpts(LOpts), TheModule(M), VFS(std::move(VFS)), | ||
| CodeGenerationTime("codegen", "Code Generation Time"), | ||
| TargetTriple(TheModule->getTargetTriple()) {} | ||
|
|
||
| ~EmitAssemblyHelper() { | ||
|
|
@@ -222,8 +220,8 @@ class EmitAssemblyHelper { | |
| std::unique_ptr<TargetMachine> TM; | ||
|
|
||
| // Emit output using the new pass manager for the optimization pipeline. | ||
| void EmitAssembly(BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS, | ||
| BackendConsumer *BC); | ||
| void emitAssembly(const CompilerInstance &CI, BackendAction Action, | ||
| std::unique_ptr<raw_pwrite_stream> OS, BackendConsumer *BC); | ||
| }; | ||
| } // namespace | ||
|
|
||
|
|
@@ -1212,10 +1210,10 @@ void EmitAssemblyHelper::RunCodegenPipeline( | |
| } | ||
| } | ||
|
|
||
| void EmitAssemblyHelper::EmitAssembly(BackendAction Action, | ||
| void EmitAssemblyHelper::emitAssembly(const CompilerInstance &CI, | ||
| BackendAction Action, | ||
| std::unique_ptr<raw_pwrite_stream> OS, | ||
| BackendConsumer *BC) { | ||
| TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr); | ||
| setCommandLineOpts(CodeGenOpts); | ||
|
|
||
| bool RequiresCodeGen = actionRequiresCodeGen(Action); | ||
|
|
@@ -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([&] { | ||
|
||
| if (!CGOpts.TimePasses) | ||
| return; | ||
| timer.stopTimer(); | ||
| CI.getFrontendTimer().startTimer(); | ||
| }); | ||
|
|
||
| std::unique_ptr<llvm::Module> EmptyModule; | ||
| if (!CGOpts.ThinLTOIndexFile.empty()) { | ||
|
|
@@ -1394,7 +1408,7 @@ void clang::EmitBackendOutput( | |
| } | ||
|
|
||
| EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M, VFS); | ||
| AsmHelper.EmitAssembly(Action, std::move(OS), BC); | ||
| AsmHelper.emitAssembly(CI, Action, std::move(OS), BC); | ||
|
|
||
| // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's | ||
| // DataLayout. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope there is a way to unify those two timers, at least the scope of them.