On Feb 28, 2012, at 6:39 PM, Daniel Dunbar wrote: > 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...
Then moving the "llvm::DenseMap<uint64_t, Stmt *> StmtEntries" out of ASTReader::ReadStmtFromStream would be goodness as well. -Argyrios > > 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); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
