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 | 08f012900320664f6bc41082cc0e14460b35422f (patch) | |
tree | 87abb541b423046461619dda86567f89bf52a773 /clang/lib/Frontend/PCHWriter.cpp | |
parent | 6fdd57cba86bdfeae99987b001f965f69d0e6704 (diff) | |
download | bcm5719-llvm-08f012900320664f6bc41082cc0e14460b35422f.tar.gz bcm5719-llvm-08f012900320664f6bc41082cc0e14460b35422f.zip |
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.
llvm-svn: 69393
Diffstat (limited to 'clang/lib/Frontend/PCHWriter.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index 5775ac4c135..64bf3833b4f 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/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) { |