[cfe-commits] r70326 - in /cfe/trunk/lib/Frontend: PCHReader.cpp PCHWriter.cpp
Douglas Gregor
dgregor at apple.com
Tue Apr 28 14:32:13 PDT 2009
Author: dgregor
Date: Tue Apr 28 16:32:13 2009
New Revision: 70326
URL: http://llvm.org/viewvc/llvm-project?rev=70326&view=rev
Log:
Optimize IdentifierInfo storage within the precompiled header. We've
now gotten back about 180k of the 500k we lost.
Modified:
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=70326&r1=70325&r2=70326&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Tue Apr 28 16:32:13 2009
@@ -237,7 +237,7 @@
return II;
}
- uint32_t Bits = ReadUnalignedLE32(d);
+ unsigned Bits = ReadUnalignedLE16(d);
bool CPlusPlusOperatorKeyword = Bits & 0x01;
Bits >>= 1;
bool Poisoned = Bits & 0x01;
@@ -248,11 +248,9 @@
Bits >>= 1;
unsigned ObjCOrBuiltinID = Bits & 0x3FF;
Bits >>= 10;
- unsigned TokenID = Bits & 0xFF;
- Bits >>= 8;
assert(Bits == 0 && "Extra bits in the identifier?");
- DataLen -= 8;
+ DataLen -= 6;
// Build the IdentifierInfo itself and link the identifier ID with
// the new IdentifierInfo.
@@ -264,9 +262,6 @@
// 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");
@@ -279,9 +274,9 @@
// If this identifier is a macro, deserialize the macro
// definition.
if (hasMacroDefinition) {
- uint32_t Offset = ReadUnalignedLE64(d);
+ uint32_t Offset = ReadUnalignedLE32(d);
Reader.ReadMacroRecord(Offset);
- DataLen -= 8;
+ DataLen -= 4;
}
// Read all of the declarations visible at global scope with this
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=70326&r1=70325&r2=70326&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Tue Apr 28 16:32:13 2009
@@ -1322,10 +1322,10 @@
unsigned KeyLen = strlen(II->getName()) + 1;
unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
if (isInterestingIdentifier(II)) {
- DataLen += 4; // 4 bytes for token ID, builtin, flags
+ DataLen += 2; // 2 bytes for builtin ID, flags
if (II->hasMacroDefinition() &&
!PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro())
- DataLen += 8;
+ DataLen += 4;
for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
DEnd = IdentifierResolver::end();
D != DEnd; ++D)
@@ -1353,21 +1353,21 @@
clang::io::Emit32(Out, ID << 1);
return;
}
+
clang::io::Emit32(Out, (ID << 1) | 0x01);
uint32_t Bits = 0;
bool hasMacroDefinition =
II->hasMacroDefinition() &&
!PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro();
- Bits = Bits | (uint32_t)II->getTokenID();
- Bits = (Bits << 10) | (uint32_t)II->getObjCOrBuiltinID();
+ Bits = (uint32_t)II->getObjCOrBuiltinID();
Bits = (Bits << 1) | hasMacroDefinition;
Bits = (Bits << 1) | II->isExtensionToken();
Bits = (Bits << 1) | II->isPoisoned();
Bits = (Bits << 1) | II->isCPlusPlusOperatorKeyword();
- clang::io::Emit32(Out, Bits);
+ clang::io::Emit16(Out, Bits);
if (hasMacroDefinition)
- clang::io::Emit64(Out, Writer.getMacroOffset(II));
+ clang::io::Emit32(Out, Writer.getMacroOffset(II));
// Emit the declaration IDs in reverse order, because the
// IdentifierResolver provides the declarations as they would be
More information about the cfe-commits
mailing list