aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 7446bdd..15311fb 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -115,8 +115,7 @@ BackendConsumer::BackendConsumer(CompilerInstance &CI, BackendAction Action,
llvm::Module *CurLinkModule)
: CI(CI), Diags(CI.getDiagnostics()), CodeGenOpts(CI.getCodeGenOpts()),
TargetOpts(CI.getTargetOpts()), LangOpts(CI.getLangOpts()),
- AsmOutStream(std::move(OS)), FS(VFS),
- LLVMIRGeneration("irgen", "LLVM IR Generation Time"), Action(Action),
+ AsmOutStream(std::move(OS)), FS(VFS), Action(Action),
Gen(CreateLLVMCodeGen(Diags, InFile, std::move(VFS),
CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(),
CI.getCodeGenOpts(), C, CoverageInfo)),
@@ -124,6 +123,8 @@ BackendConsumer::BackendConsumer(CompilerInstance &CI, BackendAction Action,
TimerIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
+ if (CodeGenOpts.TimePasses)
+ LLVMIRGeneration.init("irgen", "LLVM IR generation", CI.getTimerGroup());
}
llvm::Module* BackendConsumer::getModule() const {
@@ -162,19 +163,13 @@ bool BackendConsumer::HandleTopLevelDecl(DeclGroupRef D) {
"LLVM IR generation of declaration");
// Recurse.
- if (TimerIsEnabled) {
- LLVMIRGenerationRefCount += 1;
- if (LLVMIRGenerationRefCount == 1)
- LLVMIRGeneration.startTimer();
- }
+ if (TimerIsEnabled && !LLVMIRGenerationRefCount++)
+ CI.getFrontendTimer().yieldTo(LLVMIRGeneration);
Gen->HandleTopLevelDecl(D);
- if (TimerIsEnabled) {
- LLVMIRGenerationRefCount -= 1;
- if (LLVMIRGenerationRefCount == 0)
- LLVMIRGeneration.stopTimer();
- }
+ if (TimerIsEnabled && !--LLVMIRGenerationRefCount)
+ LLVMIRGeneration.yieldTo(CI.getFrontendTimer());
return true;
}
@@ -184,12 +179,12 @@ void BackendConsumer::HandleInlineFunctionDefinition(FunctionDecl *D) {
Context->getSourceManager(),
"LLVM IR generation of inline function");
if (TimerIsEnabled)
- LLVMIRGeneration.startTimer();
+ CI.getFrontendTimer().yieldTo(LLVMIRGeneration);
Gen->HandleInlineFunctionDefinition(D);
if (TimerIsEnabled)
- LLVMIRGeneration.stopTimer();
+ LLVMIRGeneration.yieldTo(CI.getFrontendTimer());
}
void BackendConsumer::HandleInterestingDecl(DeclGroupRef D) {
@@ -239,19 +234,13 @@ void BackendConsumer::HandleTranslationUnit(ASTContext &C) {
{
llvm::TimeTraceScope TimeScope("Frontend");
PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
- if (TimerIsEnabled) {
- LLVMIRGenerationRefCount += 1;
- if (LLVMIRGenerationRefCount == 1)
- LLVMIRGeneration.startTimer();
- }
+ if (TimerIsEnabled && !LLVMIRGenerationRefCount++)
+ CI.getFrontendTimer().yieldTo(LLVMIRGeneration);
Gen->HandleTranslationUnit(C);
- if (TimerIsEnabled) {
- LLVMIRGenerationRefCount -= 1;
- if (LLVMIRGenerationRefCount == 0)
- LLVMIRGeneration.stopTimer();
- }
+ if (TimerIsEnabled && !--LLVMIRGenerationRefCount)
+ LLVMIRGeneration.yieldTo(CI.getFrontendTimer());
IRGenFinished = true;
}