]> granicus.if.org Git - clang/commitdiff
ASTWriter: Cache some DenseMaps we use repeatedly.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 29 Feb 2012 02:39:13 +0000 (02:39 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 29 Feb 2012 02:39:13 +0000 (02:39 +0000)
 - 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...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151697 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTWriter.h
lib/Serialization/ASTWriterStmt.cpp

index f6a2c4817a5321b124640ad84d8549582dac2d30..a0ea220b2dcb1aed8bf72999d5c6faee7cc82bb9 100644 (file)
@@ -207,6 +207,18 @@ private:
   /// 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;
index 4f766d9b924565e5092fdd8d462a476427097996..22fdfe162a38086882cd22182674fa9a5f6a7a33 100644 (file)
@@ -1586,11 +1586,10 @@ void ASTWriter::WriteSubStmt(Stmt *S,
 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);