[cfe-commits] r151697 - in /cfe/trunk: include/clang/Serialization/ASTWriter.h lib/Serialization/ASTWriterStmt.cpp
Daniel Dunbar
daniel at zuster.org
Tue Feb 28 18:39:13 PST 2012
Author: ddunbar
Date: Tue Feb 28 20:39:13 2012
New Revision: 151697
URL: http://llvm.org/viewvc/llvm-project?rev=151697&view=rev
Log:
ASTWriter: Cache some DenseMaps we use repeatedly.
- This reduces our total # of allocations building a PCH for Cocoa.h by almost
a whopping 50%.
- A SmallPtrMap would be cleaner, but since we don't have one yet...
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=151697&r1=151696&r2=151697&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Feb 28 20:39:13 2012
@@ -207,6 +207,18 @@
/// IdentifierInfo.
llvm::DenseMap<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
+ /// @name FlushStmt Caches
+ /// @{
+
+ /// \brief Set of parent Stmts for the currently serializing sub stmt.
+ llvm::DenseSet<Stmt *> ParentStmts;
+
+ /// \brief Offsets of sub stmts already serialized. The offset points
+ /// just after the stmt record.
+ llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
+
+ /// @}
+
/// \brief Offsets of each of the identifier IDs into the identifier
/// table.
std::vector<uint32_t> IdentifierOffsets;
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=151697&r1=151696&r2=151697&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Tue Feb 28 20:39:13 2012
@@ -1586,11 +1586,10 @@
void ASTWriter::FlushStmts() {
RecordData Record;
- /// \brief Set of parent Stmts for the currently serializing sub stmt.
- llvm::DenseSet<Stmt *> ParentStmts;
- /// \brief Offsets of sub stmts already serialized. The offset points
- /// just after the stmt record.
- llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
+ // We expect to be the only consumer of the two temporary statement maps,
+ // assert that they are empty.
+ assert(SubStmtEntries.empty() && "unexpected entries in sub stmt map");
+ assert(ParentStmts.empty() && "unexpected entries in parent stmt map");
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
WriteSubStmt(StmtsToEmit[I], SubStmtEntries, ParentStmts);
More information about the cfe-commits
mailing list