]> granicus.if.org Git - clang/commitdiff
Changed the serialization of IdentifierTable to only serialize out entries
authorTed Kremenek <kremenek@apple.com>
Sat, 10 Nov 2007 02:11:55 +0000 (02:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 10 Nov 2007 02:11:55 +0000 (02:11 +0000)
that are referenced in the ASTs. This assumes that we serialize out the
decls/stmts first, and use the pointer-tracking logic in the Serializer to
determine if an IdentifierInfo (or its string key) is ever referenced.

This is a significant space optimization for serialized ASTs.

Consider the following program:

void foo(int x,int y) {
  return x > y ? x : y+1;
}

Here are the sizes of the files for the serialized ASTs:

        Full IdentifierTable: 23676 bytes
 Only-referenced Identifiers:   304 bytes.

For this simple program, this is a 77% reduction in the file size of the
serialized ASTs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43975 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/IdentifierTable.cpp

index 48fb0868524ee9a632f6adc7cecda4f3fd135eea..f7f008220ff3a4a1a74ed8b8d04781c686796de8 100644 (file)
@@ -415,8 +415,8 @@ void IdentifierTable::Emit(llvm::Serializer& S) const {
     const char* Key = I->getKeyData();
     const IdentifierInfo* Info = &I->getValue();
     
-    bool KeyRegistered = true; // FIXME: S.isRegistered(Key);
-    bool InfoRegistered = true; // FIXME: S.isRegistered(Info);
+    bool KeyRegistered = S.isRegistered(Key);
+    bool InfoRegistered = S.isRegistered(Info);
     
     if (KeyRegistered || InfoRegistered) {
       // These acrobatics are so that we don't incur the cost of registering