summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-22 18:49:13 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-22 18:49:13 +0000
commit4621c6ae15fb08e324e1b4e613cde5729e2a5c1a (patch)
tree76b9c64288e46f0b4f0ffa9143c8875c45d4f323 /clang/lib/Frontend/PCHReader.cpp
parent6c867a1460a01866e6dcaffdc8320f6784e327a5 (diff)
downloadbcm5719-llvm-4621c6ae15fb08e324e1b4e613cde5729e2a5c1a.tar.gz
bcm5719-llvm-4621c6ae15fb08e324e1b4e613cde5729e2a5c1a.zip
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%) llvm-svn: 69815
Diffstat (limited to 'clang/lib/Frontend/PCHReader.cpp')
-rw-r--r--clang/lib/Frontend/PCHReader.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index 031b71fbac6..976b98dd11c 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud