From 518bd14f2deedf92c96f5fc4b4c61e49eaadb16e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 25 Apr 2009 20:21:25 +0000 Subject: Start implementing the PTH IdentifierInfo-saving trick in PCH, allocating IdentifierInfos with a pointer into the string data stored in the PCH file rather than having an entry in the identifier table's string map. However, we don't actually get these savings at the moment, because we go through the IdentifierTable when loading identifiers from the on-disk hash table. This commit is for record-keeping purposes only. I'll be reverting this change (and the PCH layout tweak that preceded it) because it appears that implementing this optimization will collide with another, future optimization to reduce the size of the on-disk hash table for identifiers. That optimization is likely to provide more benefit (with less voodoo). llvm-svn: 70070 --- clang/lib/Frontend/PCHReader.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend/PCHReader.cpp') diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 2d894774a16..918fd93fdd3 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -1282,8 +1282,7 @@ public: // the new IdentifierInfo. IdentifierInfo *II = KnownII; if (!II) - II = &Reader.getIdentifierTable().CreateIdentifierInfo( - k.first, k.first + k.second); + II = &Reader.BuildIdentifierInfoInsidePCH((const unsigned char *)k.first); Reader.SetIdentifierInfo(ID, II); // Set or check the various bits in the IdentifierInfo structure. @@ -2849,6 +2848,19 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { return IdentifiersLoaded[ID - 1]; } +IdentifierInfo & +PCHReader::BuildIdentifierInfoInsidePCH(const unsigned char *Str) { + // Allocate the object. + std::pair *Mem = + Alloc.Allocate >(); + + // Build the IdentifierInfo itself. + Mem->second = Str; + assert(Str[0] != '\0'); + IdentifierInfo *II = new ((void*) Mem) IdentifierInfo(); + return *II; +} + Selector PCHReader::DecodeSelector(unsigned ID) { if (ID == 0) return Selector(); -- cgit v1.2.3