diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-25 19:10:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-25 19:10:14 +0000 |
commit | 0e14997758d18a3dfa8c74e66b6709424cb26b33 (patch) | |
tree | d5e773e5f02877644ef2895b725fec2053530f81 /clang/lib/Frontend/PCHWriter.cpp | |
parent | b28fe9eae63d8a6ca49eaeb5227f50ddd5c5b972 (diff) | |
download | bcm5719-llvm-0e14997758d18a3dfa8c74e66b6709424cb26b33.tar.gz bcm5719-llvm-0e14997758d18a3dfa8c74e66b6709424cb26b33.zip |
Write the identifier offsets array into the PCH file as a blob, so
that the PCH reader does not have to decode the VBR encoding at PCH
load time.
Also, reduce the size of the identifier offsets from 64 bits down to
32 bits. The identifier table itself isn't going to grow to more than
4GB :)
Overall, this results in a 13% speedup in the Cocoa-prefixed "Hello,
World" benchmark.
llvm-svn: 70063
Diffstat (limited to 'clang/lib/Frontend/PCHWriter.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHWriter.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp index 91ddbf41826..4ac836419eb 100644 --- a/clang/lib/Frontend/PCHWriter.cpp +++ b/clang/lib/Frontend/PCHWriter.cpp @@ -2119,7 +2119,18 @@ void PCHWriter::WriteIdentifierTable(Preprocessor &PP) { } // Write the offsets table for identifier IDs. - Stream.EmitRecord(pch::IDENTIFIER_OFFSET, IdentifierOffsets); + BitCodeAbbrev *Abbrev = new BitCodeAbbrev(); + Abbrev->Add(BitCodeAbbrevOp(pch::IDENTIFIER_OFFSET)); + Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of identifiers + Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); + unsigned IdentifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev); + + RecordData Record; + Record.push_back(pch::IDENTIFIER_OFFSET); + Record.push_back(IdentifierOffsets.size()); + Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record, + (const char *)&IdentifierOffsets.front(), + IdentifierOffsets.size() * sizeof(uint32_t)); } /// \brief Write a record containing the given attributes. @@ -2253,7 +2264,7 @@ void PCHWriter::AddString(const std::string &Str, RecordData &Record) { /// \brief Note that the identifier II occurs at the given offset /// within the identifier table. void PCHWriter::SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset) { - IdentifierOffsets[IdentifierIDs[II] - 1] = (Offset << 1) | 0x01; + IdentifierOffsets[IdentifierIDs[II] - 1] = Offset; } /// \brief Note that the selector Sel occurs at the given offset |