[PATCH] D36848: [CodeGen] Use reentrant methods to time IR gen
Brian Gesiak via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 22 09:33:11 PDT 2017
modocache updated this revision to Diff 112187.
modocache retitled this revision from "[CodeGen] Use RefCntTimer to time IR generation" to "[CodeGen] Use reentrant methods to time IR gen".
modocache edited the summary of this revision.
modocache added a comment.
Use `startReentrantTimer` and `stopReentrantTimer`
https://reviews.llvm.org/D36848
Files:
lib/CodeGen/CodeGenAction.cpp
Index: lib/CodeGen/CodeGenAction.cpp
===================================================================
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -60,7 +60,6 @@
ASTContext *Context;
Timer LLVMIRGeneration;
- unsigned LLVMIRGenerationRefCount;
/// True if we've finished generating IR. This prevents us from generating
/// additional LLVM IR after emitting output in HandleTranslationUnit. This
@@ -90,7 +89,6 @@
CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
AsmOutStream(std::move(OS)), Context(nullptr),
LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
- LLVMIRGenerationRefCount(0),
Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
CodeGenOpts, C, CoverageInfo)),
LinkModules(std::move(LinkModules)) {
@@ -113,33 +111,27 @@
Context = &Ctx;
if (llvm::TimePassesIsEnabled)
- LLVMIRGeneration.startTimer();
+ LLVMIRGeneration.startReentrantTimer();
Gen->Initialize(Ctx);
if (llvm::TimePassesIsEnabled)
- LLVMIRGeneration.stopTimer();
+ LLVMIRGeneration.stopReentrantTimer();
}
bool HandleTopLevelDecl(DeclGroupRef D) override {
PrettyStackTraceDecl CrashInfo(*D.begin(), SourceLocation(),
Context->getSourceManager(),
"LLVM IR generation of declaration");
// Recurse.
- if (llvm::TimePassesIsEnabled) {
- LLVMIRGenerationRefCount += 1;
- if (LLVMIRGenerationRefCount == 1)
- LLVMIRGeneration.startTimer();
- }
+ if (llvm::TimePassesIsEnabled)
+ LLVMIRGeneration.startReentrantTimer();
Gen->HandleTopLevelDecl(D);
- if (llvm::TimePassesIsEnabled) {
- LLVMIRGenerationRefCount -= 1;
- if (LLVMIRGenerationRefCount == 0)
- LLVMIRGeneration.stopTimer();
- }
+ if (llvm::TimePassesIsEnabled)
+ LLVMIRGeneration.stopReentrantTimer();
return true;
}
@@ -149,12 +141,12 @@
Context->getSourceManager(),
"LLVM IR generation of inline function");
if (llvm::TimePassesIsEnabled)
- LLVMIRGeneration.startTimer();
+ LLVMIRGeneration.startReentrantTimer();
Gen->HandleInlineFunctionDefinition(D);
if (llvm::TimePassesIsEnabled)
- LLVMIRGeneration.stopTimer();
+ LLVMIRGeneration.stopReentrantTimer();
}
void HandleInterestingDecl(DeclGroupRef D) override {
@@ -195,19 +187,13 @@
void HandleTranslationUnit(ASTContext &C) override {
{
PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
- if (llvm::TimePassesIsEnabled) {
- LLVMIRGenerationRefCount += 1;
- if (LLVMIRGenerationRefCount == 1)
- LLVMIRGeneration.startTimer();
- }
+ if (llvm::TimePassesIsEnabled)
+ LLVMIRGeneration.startReentrantTimer();
Gen->HandleTranslationUnit(C);
- if (llvm::TimePassesIsEnabled) {
- LLVMIRGenerationRefCount -= 1;
- if (LLVMIRGenerationRefCount == 0)
- LLVMIRGeneration.stopTimer();
- }
+ if (llvm::TimePassesIsEnabled)
+ LLVMIRGeneration.stopReentrantTimer();
IRGenFinished = true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36848.112187.patch
Type: text/x-patch
Size: 3452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170822/bc02d8f5/attachment-0001.bin>
More information about the cfe-commits
mailing list