summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHWriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-25 18:35:21 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-25 18:35:21 +0000
commit745ed14636c202d3bcc390f75e80b055ca7d3d05 (patch)
treee568cf010b213b966927623189a4df509b330d3c /clang/lib/Frontend/PCHWriter.cpp
parentb869a0ade10a150b06b227572f5a19b9037fdde2 (diff)
downloadbcm5719-llvm-745ed14636c202d3bcc390f75e80b055ca7d3d05.tar.gz
bcm5719-llvm-745ed14636c202d3bcc390f75e80b055ca7d3d05.zip
Write the declaration and type offset arrays into the bitstream as
blobs, so that we don't need to do any work to get these arrays into memory at PCH load time. This gives another 19% performance improvement to the Cocoa-prefixed "Hello, World!". llvm-svn: 70059
Diffstat (limited to 'clang/lib/Frontend/PCHWriter.cpp')
-rw-r--r--clang/lib/Frontend/PCHWriter.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp
index 56c8296c949..91ddbf41826 100644
--- a/clang/lib/Frontend/PCHWriter.cpp
+++ b/clang/lib/Frontend/PCHWriter.cpp
@@ -2270,6 +2270,8 @@ PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
NumVisibleDeclContexts(0) { }
void PCHWriter::WritePCH(Sema &SemaRef) {
+ using namespace llvm;
+
ASTContext &Context = SemaRef.Context;
Preprocessor &PP = SemaRef.PP;
@@ -2315,7 +2317,7 @@ void PCHWriter::WritePCH(Sema &SemaRef) {
// Write the remaining PCH contents.
RecordData Record;
- Stream.EnterSubblock(pch::PCH_BLOCK_ID, 3);
+ Stream.EnterSubblock(pch::PCH_BLOCK_ID, 4);
WriteTargetTriple(Context.Target);
WriteLanguageOptions(Context.getLangOptions());
WriteSourceManagerBlock(Context.getSourceManager());
@@ -2324,8 +2326,32 @@ void PCHWriter::WritePCH(Sema &SemaRef) {
WriteDeclsBlock(Context);
WriteMethodPool(SemaRef);
WriteIdentifierTable(PP);
- Stream.EmitRecord(pch::TYPE_OFFSET, TypeOffsets);
- Stream.EmitRecord(pch::DECL_OFFSET, DeclOffsets);
+
+ // Write the type offsets array
+ BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+ Abbrev->Add(BitCodeAbbrevOp(pch::TYPE_OFFSET));
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of types
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // types block
+ unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
+ Record.clear();
+ Record.push_back(pch::TYPE_OFFSET);
+ Record.push_back(TypeOffsets.size());
+ Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
+ (const char *)&TypeOffsets.front(),
+ TypeOffsets.size() * sizeof(uint64_t));
+
+ // Write the declaration offsets array
+ Abbrev = new BitCodeAbbrev();
+ Abbrev->Add(BitCodeAbbrevOp(pch::DECL_OFFSET));
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of declarations
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // declarations block
+ unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
+ Record.clear();
+ Record.push_back(pch::DECL_OFFSET);
+ Record.push_back(DeclOffsets.size());
+ Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
+ (const char *)&DeclOffsets.front(),
+ DeclOffsets.size() * sizeof(uint64_t));
// Write the record of special types.
Record.clear();
OpenPOWER on IntegriCloud