diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-22 18:49:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-22 18:49:13 +0000 |
commit | 2deaea37a637dd01221d0cced343702a39d8132c (patch) | |
tree | ece1730c3fad98b022a242caf6f2e2b6933836e2 /lib/Frontend/PCHReader.cpp | |
parent | 404dd7afe15c9d8b614da031bbfae6a28ffaea72 (diff) |
Lazy loading of builtins for precompiled headers.
PCH files now contain complete information about builtins, including
any declarations that have been synthesized as part of building the
PCH file. When using a PCH file, we do not initialize builtins at all;
when needed, they'll be found in the PCH file.
This optimization translations into a 9% speedup for "Hello, World!"
with Carbon.h as a prefix header and roughly a 5% speedup for 403.gcc
with its prefix header. We're also reading less of the PCH file for
"Hello, World!":
*** PCH Statistics:
286/20693 types read (1.382110%)
1630/59230 declarations read (2.751984%)
764/44914 identifiers read (1.701029%)
1/32954 statements read (0.003035%)
5/6187 macros read (0.080815%)
down from
*** PCH Statistics:
411/20693 types read (1.986179%)
2553/59230 declarations read (4.310316%)
1093/44646 identifiers read (2.448148%)
1/32954 statements read (0.003035%)
21/6187 macros read (0.339421%)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69815 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 031b71fbac..976b98dd11 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1110,10 +1110,21 @@ public: unsigned DataLen) { using namespace clang::io; uint32_t Bits = ReadUnalignedLE32(d); // FIXME: use these? - (void)Bits; - bool hasMacroDefinition = (Bits >> 3) & 0x01; - + bool CPlusPlusOperatorKeyword = Bits & 0x01; + Bits >>= 1; + bool Poisoned = Bits & 0x01; + Bits >>= 1; + bool ExtensionToken = Bits & 0x01; + Bits >>= 1; + bool hasMacroDefinition = Bits & 0x01; + Bits >>= 1; + unsigned ObjCOrBuiltinID = Bits & 0x3FF; + Bits >>= 10; + unsigned TokenID = Bits & 0xFF; + Bits >>= 8; + pch::IdentID ID = ReadUnalignedLE32(d); + assert(Bits == 0 && "Extra bits in the identifier?"); DataLen -= 8; // Build the IdentifierInfo itself and link the identifier ID with @@ -1124,6 +1135,20 @@ public: k.first, k.first + k.second); Reader.SetIdentifierInfo(ID, II); + // Set or check the various bits in the IdentifierInfo structure. + // FIXME: Load token IDs lazily, too? + assert((unsigned)II->getTokenID() == TokenID && + "Incorrect token ID loaded"); + (void)TokenID; + II->setObjCOrBuiltinID(ObjCOrBuiltinID); + assert(II->isExtensionToken() == ExtensionToken && + "Incorrect extension token flag"); + (void)ExtensionToken; + II->setIsPoisoned(Poisoned); + assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword && + "Incorrect C++ operator keyword flag"); + (void)CPlusPlusOperatorKeyword; + // If this identifier is a macro, deserialize the macro // definition. if (hasMacroDefinition) { |