From 0e14997758d18a3dfa8c74e66b6709424cb26b33 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 25 Apr 2009 19:10:14 +0000 Subject: 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 --- clang/lib/Frontend/PCHWriter.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend/PCHWriter.cpp') 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 -- cgit v1.2.3