/// reported to the AST consumer after the PCH file has been
/// read, since their presence can affect the semantics of the
/// program (e.g., for code generation).
- EXTERNAL_DEFINITIONS = 7
+ EXTERNAL_DEFINITIONS = 7,
+
+ /// \brief Record code for the block of extra statistics we
+ /// gather while generating a PCH file.
+ STATISTICS = 8
};
/// \brief Record types used within a source manager block.
/// been de-serialized.
std::multimap<unsigned, AddrLabelExpr *> UnresolvedAddrLabelExprs;
+ /// \brief The number of statements (and expressions) de-serialized
+ /// from the PCH file.
+ unsigned NumStatementsRead;
+
+ /// \brief The total number of statements (and expressions) stored
+ /// in the PCH file.
+ unsigned TotalNumStatements;
+
PCHReadResult ReadPCHBlock();
bool CheckPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
typedef llvm::SmallVector<uint64_t, 64> RecordData;
PCHReader(Preprocessor &PP, ASTContext &Context)
- : PP(PP), Context(Context), IdentifierTable(0) { }
+ : PP(PP), Context(Context), IdentifierTable(0), NumStatementsRead(0) { }
~PCHReader() {}
/// \brief Mapping from LabelStmt statements to IDs.
std::map<LabelStmt *, unsigned> LabelIDs;
+ /// \brief The number of statements written to the PCH file.
+ unsigned NumStatements;
+
void WriteTargetTriple(const TargetInfo &Target);
void WriteLanguageOptions(const LangOptions &LangOpts);
void WriteSourceManagerBlock(SourceManager &SourceMgr);
}
uint64_t PreprocessorBlockBit = 0;
-
+
// Read all of the records and blocks for the PCH file.
RecordData Record;
while (!Stream.AtEndOfStream()) {
}
ExternalDefinitions.swap(Record);
break;
+
+ case pch::STATISTICS:
+ TotalNumStatements = Record[0];
+ break;
+
}
}
std::fprintf(stderr, " %u/%u identifiers read (%f%%)\n",
NumIdentifiersLoaded, (unsigned)IdentifierData.size(),
((float)NumIdentifiersLoaded/IdentifierData.size() * 100));
+ std::fprintf(stderr, " %u/%u statements read (%f%%)\n",
+ NumStatementsRead, TotalNumStatements,
+ ((float)NumStatementsRead/TotalNumStatements * 100));
std::fprintf(stderr, "\n");
}
if (Finished)
break;
+ ++NumStatementsRead;
+
if (S) {
unsigned NumSubStmts = Reader.Visit(S);
while (NumSubStmts > 0) {
}
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.
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();
}
void PCHWriter::WriteSubStmt(Stmt *S) {
RecordData Record;
PCHStmtWriter Writer(*this, Record);
+ ++NumStatements;
if (!S) {
Stream.EmitRecord(pch::STMT_NULL_PTR, Record);
PCHStmtWriter Writer(*this, Record);
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
+ ++NumStatements;
Stmt *S = StmtsToEmit[I];
if (!S) {