diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-17 22:13:46 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-17 22:13:46 +0000 |
commit | 3e1af84bb0092a1aafb49deaa4ab6664c9a9071b (patch) | |
tree | 8bd3ab39182cefb3f3e8ca16debf47c739716b6e /lib/Frontend/PCHWriter.cpp | |
parent | 96508e1fea58347b6401ca9a4728c0b268174603 (diff) |
Keep track of the number of statements/expressions written to and read
from a PCH file. It turns out that "Hello, World!" is bringing in 19%
of all of the statements in Carbon.h, so we need to be lazy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHWriter.cpp')
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 5775ac4c13..64bf3833b4 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1723,7 +1723,7 @@ void PCHWriter::AddString(const std::string &Str, RecordData &Record) { } PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream) - : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS) { } + : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS), NumStatements(0) { } void PCHWriter::WritePCH(ASTContext &Context, const Preprocessor &PP) { // Emit the file header. @@ -1749,6 +1749,11 @@ void PCHWriter::WritePCH(ASTContext &Context, const Preprocessor &PP) { Stream.EmitRecord(pch::DECL_OFFSET, DeclOffsets); if (!ExternalDefinitions.empty()) Stream.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions); + + // Some simple statistics + RecordData Record; + Record.push_back(NumStatements); + Stream.EmitRecord(pch::STATISTICS, Record); Stream.ExitBlock(); } @@ -1880,6 +1885,7 @@ void PCHWriter::AddDeclarationName(DeclarationName Name, RecordData &Record) { void PCHWriter::WriteSubStmt(Stmt *S) { RecordData Record; PCHStmtWriter Writer(*this, Record); + ++NumStatements; if (!S) { Stream.EmitRecord(pch::STMT_NULL_PTR, Record); @@ -1900,6 +1906,7 @@ void PCHWriter::FlushStmts() { PCHStmtWriter Writer(*this, Record); for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) { + ++NumStatements; Stmt *S = StmtsToEmit[I]; if (!S) { |