[cfe-commits] r70216 - in /cfe/trunk: include/clang/Frontend/PCHReader.h include/clang/Frontend/PCHWriter.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp

Chris Lattner sabre at nondot.org
Mon Apr 27 11:24:18 PDT 2009


Author: lattner
Date: Mon Apr 27 13:24:17 2009
New Revision: 70216

URL: http://llvm.org/viewvc/llvm-project?rev=70216&view=rev
Log:
encode the type and decl offsets with 32-bits for entry instead
of 64 bits.  This cuts 400KB off the PCH file for cocoa (7.1 -> 
6.7MB):

Before:

	Record Histogram:
		  Count    # Bits   % Abv  Record Kind
		      1     14296          SOURCE_LOCATION_PRELOADS
		      1   1699598  100.00  SOURCE_LOCATION_OFFSETS
		      1   1870766  100.00  METHOD_POOL
		      1    212988  100.00  SELECTOR_OFFSETS
		      1        88          STATISTICS
		      1       106          SPECIAL_TYPES
		      1  18033788  100.00  IDENTIFIER_TABLE
		      1   1806428  100.00  IDENTIFIER_OFFSET
		      1       170  100.00  TARGET_TRIPLE
		      1       268          LANGUAGE_OPTIONS
		      1   5168252  100.00  DECL_OFFSET
		      1    952700  100.00  TYPE_OFFSET

After:

	Record Histogram:
		  Count    # Bits   % Abv  Record Kind
		      1     14296          SOURCE_LOCATION_PRELOADS
		      1   1699598  100.00  SOURCE_LOCATION_OFFSETS
		      1   1870766  100.00  METHOD_POOL
		      1    212988  100.00  SELECTOR_OFFSETS
		      1        88          STATISTICS
		      1       106          SPECIAL_TYPES
		      1  18033788  100.00  IDENTIFIER_TABLE
		      1   1806428  100.00  IDENTIFIER_OFFSET
		      1       170  100.00  TARGET_TRIPLE
		      1       268          LANGUAGE_OPTIONS
		      1   2584156  100.00  DECL_OFFSET
		      1    476380  100.00  TYPE_OFFSET


Modified:
    cfe/trunk/include/clang/Frontend/PCHReader.h
    cfe/trunk/include/clang/Frontend/PCHWriter.h
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Frontend/PCHWriter.cpp

Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=70216&r1=70215&r2=70216&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Mon Apr 27 13:24:17 2009
@@ -116,7 +116,7 @@
 
   /// \brief Offset of each type within the bitstream, indexed by the
   /// type ID, or the representation of a Type*.
-  const uint64_t *TypeOffsets;
+  const uint32_t *TypeOffsets;
 
   /// \brief Types that have already been loaded from the PCH file.
   /// 
@@ -126,7 +126,7 @@
 
   /// \brief Offset of each declaration within the bitstream, indexed
   /// by the declaration ID (-1).
-  const uint64_t *DeclOffsets;
+  const uint32_t *DeclOffsets;
 
   /// \brief Declarations that have already been loaded from the PCH file.
   ///

Modified: cfe/trunk/include/clang/Frontend/PCHWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHWriter.h?rev=70216&r1=70215&r2=70216&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHWriter.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHWriter.h Mon Apr 27 13:24:17 2009
@@ -64,7 +64,7 @@
 
   /// \brief Offset of each declaration in the bitstream, indexed by
   /// the declaration's ID.
-  llvm::SmallVector<uint64_t, 16> DeclOffsets;
+  std::vector<uint32_t> DeclOffsets;
 
   /// \brief Queue containing the declarations that we still need to
   /// emit.
@@ -81,7 +81,7 @@
 
   /// \brief Offset of each type in the bitstream, indexed by
   /// the type's ID.
-  llvm::SmallVector<uint64_t, 16> TypeOffsets;
+  std::vector<uint32_t> TypeOffsets;
 
   /// \brief The type ID that will be assigned to the next new type.
   pch::TypeID NextTypeID;

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=70216&r1=70215&r2=70216&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Mon Apr 27 13:24:17 2009
@@ -793,7 +793,7 @@
         Error("Duplicate TYPE_OFFSET record in PCH file");
         return Failure;
       }
-      TypeOffsets = (const uint64_t *)BlobStart;
+      TypeOffsets = (const uint32_t *)BlobStart;
       TypesLoaded.resize(Record[0]);
       break;
 
@@ -802,7 +802,7 @@
         Error("Duplicate DECL_OFFSET record in PCH file");
         return Failure;
       }
-      DeclOffsets = (const uint64_t *)BlobStart;
+      DeclOffsets = (const uint32_t *)BlobStart;
       DeclsLoaded.resize(Record[0]);
       break;
 

Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=70216&r1=70215&r2=70216&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Mon Apr 27 13:24:17 2009
@@ -1565,7 +1565,7 @@
   Record.push_back(TypeOffsets.size());
   Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
                             (const char *)&TypeOffsets.front(), 
-                            TypeOffsets.size() * sizeof(uint64_t));
+                            TypeOffsets.size() * sizeof(TypeOffsets[0]));
   
   // Write the declaration offsets array
   Abbrev = new BitCodeAbbrev();
@@ -1578,7 +1578,7 @@
   Record.push_back(DeclOffsets.size());
   Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
                             (const char *)&DeclOffsets.front(), 
-                            DeclOffsets.size() * sizeof(uint64_t));
+                            DeclOffsets.size() * sizeof(DeclOffsets[0]));
 
   // Write the record of special types.
   Record.clear();





More information about the cfe-commits mailing list