summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-02-29 02:39:13 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-02-29 02:39:13 +0000
commita5acaa3ca8480da57476084667f8189d4986e3c7 (patch)
treececc57c5dc6e8a26c4554cb93c543f836d7f5ab6
parent7e4b976c365b592d03caaa2fc51a534736996531 (diff)
downloadbcm5719-llvm-a5acaa3ca8480da57476084667f8189d4986e3c7.tar.gz
bcm5719-llvm-a5acaa3ca8480da57476084667f8189d4986e3c7.zip
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... llvm-svn: 151697
-rw-r--r--clang/include/clang/Serialization/ASTWriter.h12
-rw-r--r--clang/lib/Serialization/ASTWriterStmt.cpp9
2 files changed, 16 insertions, 5 deletions
diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h
index f6a2c4817a5..a0ea220b2dc 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -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;
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 4f766d9b924..22fdfe162a3 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -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);
OpenPOWER on IntegriCloud