[cfe-commits] r69835 - in /cfe/trunk: include/clang/Frontend/PCHReader.h include/clang/Frontend/PCHWriter.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Douglas Gregor
dgregor at apple.com
Wed Apr 22 15:34:58 PDT 2009
Author: dgregor
Date: Wed Apr 22 17:34:57 2009
New Revision: 69835
URL: http://llvm.org/viewvc/llvm-project?rev=69835&view=rev
Log:
Add PCH statistics for the number/percent of lexical/visible declcontexts read
Modified:
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/include/clang/Frontend/PCHWriter.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=69835&r1=69834&r2=69835&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Wed Apr 22 17:34:57 2009
@@ -185,9 +185,16 @@
/// \brief The number of macros de-serialized from the PCH file.
unsigned NumMacrosRead;
+
/// \brief The total number of macros stored in the PCH file.
unsigned TotalNumMacros;
+ /// Number of lexical decl contexts read/total.
+ unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts;
+
+ /// Number of visible decl contexts read/total.
+ unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
+
/// \brief FIXME: document!
llvm::SmallVector<uint64_t, 4> SpecialTypes;
@@ -211,7 +218,8 @@
explicit PCHReader(Preprocessor &PP, ASTContext &Context)
: SemaObj(0), PP(PP), Context(Context), Consumer(0),
- IdentifierTableData(0), NumStatementsRead(0) { }
+ IdentifierTableData(0), NumStatementsRead(0), NumMacrosRead(0),
+ NumLexicalDeclContextsRead(0), NumVisibleDeclContextsRead(0) { }
~PCHReader() {}
Modified: cfe/trunk/include/clang/Frontend/PCHWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHWriter.h?rev=69835&r1=69834&r2=69835&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHWriter.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHWriter.h Wed Apr 22 17:34:57 2009
@@ -136,6 +136,14 @@
/// \brief The number of macros written to the PCH file.
unsigned NumMacros;
+ /// \brief The number of lexical declcontexts written to the PCH
+ /// file.
+ unsigned NumLexicalDeclContexts;
+
+ /// \brief The number of visible declcontexts written to the PCH
+ /// file.
+ unsigned NumVisibleDeclContexts;
+
void WriteTargetTriple(const TargetInfo &Target);
void WriteLanguageOptions(const LangOptions &LangOpts);
void WriteSourceManagerBlock(SourceManager &SourceMgr);
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69835&r1=69834&r2=69835&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Apr 22 17:34:57 2009
@@ -1711,6 +1711,8 @@
case pch::STATISTICS:
TotalNumStatements = Record[0];
TotalNumMacros = Record[1];
+ TotalLexicalDeclContexts = Record[2];
+ TotalVisibleDeclContexts = Record[3];
break;
case pch::TENTATIVE_DEFINITIONS:
@@ -2439,6 +2441,7 @@
// Load all of the declaration IDs
Decls.clear();
Decls.insert(Decls.end(), Record.begin(), Record.end());
+ ++NumLexicalDeclContextsRead;
return false;
}
@@ -2479,6 +2482,7 @@
LoadedDecls.push_back(Record[Idx++]);
}
+ ++NumVisibleDeclContextsRead;
return false;
}
@@ -2525,6 +2529,14 @@
std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
NumMacrosRead, TotalNumMacros,
((float)NumMacrosRead/TotalNumMacros * 100));
+ std::fprintf(stderr, " %u/%u lexical declcontexts read (%f%%)\n",
+ NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
+ ((float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
+ * 100));
+ std::fprintf(stderr, " %u/%u visible declcontexts read (%f%%)\n",
+ NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
+ ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
+ * 100));
std::fprintf(stderr, "\n");
}
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69835&r1=69834&r2=69835&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Apr 22 17:34:57 2009
@@ -1616,6 +1616,7 @@
D != DEnd; ++D)
AddDeclRef(*D, Record);
+ ++NumLexicalDeclContexts;
Stream.EmitRecord(pch::DECL_CONTEXT_LEXICAL, Record);
return Offset;
}
@@ -1664,6 +1665,7 @@
return 0;
Stream.EmitRecord(pch::DECL_CONTEXT_VISIBLE, Record);
+ ++NumVisibleDeclContexts;
return Offset;
}
@@ -1997,7 +1999,8 @@
PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
: Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS),
- NumStatements(0), NumMacros(0) { }
+ NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0),
+ NumVisibleDeclContexts(0) { }
void PCHWriter::WritePCH(Sema &SemaRef) {
ASTContext &Context = SemaRef.Context;
@@ -2078,6 +2081,8 @@
Record.clear();
Record.push_back(NumStatements);
Record.push_back(NumMacros);
+ Record.push_back(NumLexicalDeclContexts);
+ Record.push_back(NumVisibleDeclContexts);
Stream.EmitRecord(pch::STATISTICS, Record);
Stream.ExitBlock();
}
More information about the cfe-commits
mailing list