summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-25 21:04:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-25 21:04:17 +0000
commit5287b4e8ec8a53ee1807007e8869f1a3d3c83ec0 (patch)
tree85c0718d417d5f482974a692aa11c6197f20012f /clang/lib/Frontend/PCHReader.cpp
parent0f3b758f013b552410e6dd7f8b8bffc359c5c630 (diff)
downloadbcm5719-llvm-5287b4e8ec8a53ee1807007e8869f1a3d3c83ec0.tar.gz
bcm5719-llvm-5287b4e8ec8a53ee1807007e8869f1a3d3c83ec0.zip
PCH optimization for the identifier table, where we separate
"interesting" identifiers (e.g., those where the IdentifierInfo has some useful information) from "uninteresting" identifiers (where the IdentifierInfo is just a name). This makes the hash table smaller (so searching in it should be faster) and, when loading "uninteresting" identifiers, we skip the lookup in the hash table. PCH file size is slightly smaller than before (since we don't emit the contents of the uninteresting IdentifierInfo structures). The Cocoa.h-prefixed "Hello, World" doesn't show any speedup, although we're getting to the point where system noise is a bit issue. llvm-svn: 70075
Diffstat (limited to 'clang/lib/Frontend/PCHReader.cpp')
-rw-r--r--clang/lib/Frontend/PCHReader.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index 005436dccf2..6f1ff329772 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/lib/Frontend/PCHReader.cpp
@@ -1245,8 +1245,8 @@ public:
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
using namespace clang::io;
- unsigned KeyLen = ReadUnalignedLE16(d);
unsigned DataLen = ReadUnalignedLE16(d);
+ unsigned KeyLen = ReadUnalignedLE16(d);
return std::make_pair(KeyLen, DataLen);
}
@@ -2842,8 +2842,31 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) {
if (!IdentifiersLoaded[ID - 1]) {
uint32_t Offset = IdentifierOffsets[ID - 1];
- IdentifiersLoaded[ID - 1]
- = &Context.Idents.get(IdentifierTableData + Offset);
+
+ // If there is an identifier lookup table, but the offset of this
+ // string is after the identifier table itself, then we know that
+ // this string is not in the on-disk hash table. Therefore,
+ // disable lookup into the hash table when looking for this
+ // identifier.
+ PCHIdentifierLookupTable *IdTable
+ = (PCHIdentifierLookupTable *)IdentifierLookupTable;
+ bool SkipHashTable = IdTable &&
+ Offset >= uint32_t(IdTable->getBuckets() - IdTable->getBase());
+
+ if (SkipHashTable)
+ PP.getIdentifierTable().setExternalIdentifierLookup(0);
+
+ // All of the strings in the PCH file are preceded by a 16-bit
+ // length. Extract that 16-bit length to avoid having to run
+ // strlen().
+ const char *Str = IdentifierTableData + Offset;
+ const char *StrLenPtr = Str - 2;
+ unsigned StrLen = (((unsigned) StrLenPtr[0])
+ | (((unsigned) StrLenPtr[1]) << 8)) - 1;
+ IdentifiersLoaded[ID - 1] = &Context.Idents.get(Str, Str + StrLen);
+
+ if (SkipHashTable)
+ PP.getIdentifierTable().setExternalIdentifierLookup(this);
}
return IdentifiersLoaded[ID - 1];
OpenPOWER on IntegriCloud