aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHWriter.cpp
AgeCommit message (Collapse)Author
2009-04-27Add two new checker-specific attributes: 'objc_ownership_release' andTed Kremenek
'objc_ownership_cfrelease'. These are the 'release' equivalents of 'objc_ownership_retain' and 'objc_ownership_cfretain' respectively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27make these be unsigned now that they are eagerly created.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70229 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27shrink SOURCE_LOCATION_OFFSETS to use 4-byte entries instead of 8-byteChris Lattner
entries, shaving 100K off the PCH file for cocoa. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70228 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27Implement caching of stat() calls for precompiled headers, which isDouglas Gregor
essentially the same thing we do with pretokenized headers. stat() caching improves performance of the Cocoa-prefixed "Hello, World" by 45%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70223 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27Add new checker-specific attribute 'objc_ownership_cfretain'. This is the sameTed Kremenek
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead of a [... retain] (important in GC modes). Checker support is wired up, but currently only for Objective-C message expressions (not function calls). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70218 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27encode the type and decl offsets with 32-bits for entry insteadChris Lattner
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70216 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27add an abbreviation for common PARM_VAR_DECL. All but 9 of the Chris Lattner
parm var decls in leopard cocoa.h end up using this abbreviation, which shrinks the bitcode file by about 50K: 7217736->7167120. Before: Block ID #12 (DECLS_BLOCK): Num Instances: 1 Total Size: 2.23595e+07b/2.79494e+06B/698736W % of file: 38.7233 Num SubBlocks: 0 Num Abbrevs: 0 Num Records: 139387 % Abbrev Recs: 0 After: Block ID #12 (DECLS_BLOCK): Num Instances: 1 Total Size: 2.02405e+07b/2.53006e+06B/632516W % of file: 35.301 Num SubBlocks: 0 Num Abbrevs: 1 Num Records: 139387 % Abbrev Recs: 19.2902 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27Load most of the source manager's information lazily from the PCHDouglas Gregor
file. In particular, only eagerly load source location entries for files and for the predefines buffer. Other buffers and macro-instantiation source location entries are loaded lazily. With the Cocoa-prefixed "Hello, World", we only load 815/26555 source location entities. This halves the amount of user time we spend in this "Hello, World" program with -fsyntax-only (down to .007s). This optimization is part 1 of 2 for the source manager. This eliminates most of the user time in loading a PCH file. We still spend too much time initialize File structures (especially in the calls to stat), so we need to either make the loading of source location entries for files lazy or import the stat cache from the PTH implementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27split expr/stmt writing out to PCHWriterStmt.cppChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70194 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27split decl writing out to its own PCHWriterDecl.cpp file.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27add stmt/expr names to BlockInfo block.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70172 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27drop the _ID suffixes from block names.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70169 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26add the decl names.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70167 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26make llvm-bcanalyzer dump out PCH files symbolically. We should probablyChris Lattner
eventually get an option to turn this off, but it is nice for looking at statistics. For example, the types block now prints: Block ID #11 (TYPES_BLOCK_ID): Num Instances: 1 Total Size: 895100b/111888B/27971.9W % of file: 1.55801 Num SubBlocks: 0 Num Abbrevs: 0 Num Records: 14899 % Abbrev Recs: 0 Code Histogram: 5478 TYPE_FUNCTION_PROTO 2683 TYPE_TYPEDEF 2460 TYPE_POINTER 2047 TYPE_ENUM 1553 TYPE_RECORD 283 TYPE_CONSTANT_ARRAY 274 TYPE_OBJC_INTERFACE 76 TYPE_INCOMPLETE_ARRAY 10 TYPE_VECTOR 9 TYPE_OBJC_QUALIFIED_ID 5 TYPE_FUNCTION_NO_PROTO 5 TYPE_EXT_QUAL 3 TYPE_TYPEOF_EXPR git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70166 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26Some fixes for PCH (de-)serialization of Objective-C AST nodes:Douglas Gregor
- Deal with the Receiver/ClassInfo shared storage in ObjCMessageExpr - Implement PCH support for ImplicitParamDecl - Fix the handling of the body of an ObjCMethodDecl - Several cast -> cast_or_null fixes - Make Selector::getIdentifierInfoForSlot work for 1-argument, NULL selectors. - Make Selector::getAsString() work with NULL selectors. - Fix the names of VisitObjCAtCatchStmt and VisitObjCAtFinallyStmt in the PCH reader and writer; these were never getting called. At this point, all of the pch-test tests pass for C and Objective-C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26Add PCH read/write support for ObjC statements.Steve Naroff
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26Make sure we have a code in the node:-)Steve Naroff
This fixes all the -emit-pch problems discovered by utils/pch-test.pl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70125 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26When writing a PCH file, write multiple type and declaration blocks asDouglas Gregor
necessary and iterate until all types and declarations have been written. This reduces the Cocoa.h PCH file size by about 4% (since we don't write types we don't need), and fixes problems where writing a declaration generates a new type. This doesn't seem to have any impact on performance either way. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70109 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26split ObjC and C++ Statements out into their own headers.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70105 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26implement PCH support for the rest of ExprObjC.h, includingChris Lattner
the missing bits of ObjCMessageExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70100 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26Don't read all of the records in the PCH file's preprocessor block,Douglas Gregor
most of which are ignored. Instead, move the __COUNTER__ value out to a PCH-level record (since it is handled eagerly) and move the header file information into the SourceManager block (which is also, currently, loaded eagerly). This results in another 17% performance improvement in the Cocoa-prefixed "Hello, World" with PCH. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70097 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25PCH optimization for the identifier table, where we separateDouglas Gregor
"interesting" identifiers (e.g., those where the IdentifierInfo has some useful information) from "uninteresting" identifiers (where the IdentifierInfo is just a name). This makes the hash table smaller (so searching in it should be faster) and, when loading "uninteresting" identifiers, we skip the lookup in the hash table. PCH file size is slightly smaller than before (since we don't emit the contents of the uninteresting IdentifierInfo structures). The Cocoa.h-prefixed "Hello, World" doesn't show any speedup, although we're getting to the point where system noise is a bit issue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70075 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Revert my changes that try to avoid creating StringMap entries forDouglas Gregor
identifiers. They don't yet work, but will inhibit future optimizations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Tweak the data layout for the on-disk hash table of identifiers in the PCH ↵Douglas Gregor
file so that the key layout matches that of the PTH key layout git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70066 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Write the identifier offsets array into the PCH file as a blob, soDouglas Gregor
that the PCH reader does not have to decode the VBR encoding at PCH load time. Also, reduce the size of the identifier offsets from 64 bits down to 32 bits. The identifier table itself isn't going to grow to more than 4GB :) Overall, this results in a 13% speedup in the Cocoa-prefixed "Hello, World" benchmark. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70063 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Write the declaration and type offset arrays into the bitstream asDouglas Gregor
blobs, so that we don't need to do any work to get these arrays into memory at PCH load time. This gives another 19% performance improvement to the Cocoa-prefixed "Hello, World!". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70059 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Load the selector table lazily from the PCH file. Douglas Gregor
This results in a 10% speedup on the Cocoa-prefixed "Hello, World!", all of which is (not surprisingly) user time. There was a tiny reduction in the size of the PCH file for Cocoa.h, because certain selectors aren't being written twice. I'm using two new tricks here that I'd like to replicate elsewhere: (1) The selectors not used in the global method pool are packed into the blob after the global method pool's on-disk hash table and stored as keys, so that all selectors are in the same blob. (2) We record the offsets of each selector key when we write it into the global method pool (or after it, in the same blob). The offset table is written as a blob, so that we don't need to pack/unpack a SmallVector with its contents. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Add PCH support for ObjCMessageExpr (needed to build Mail).Steve Naroff
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Fix a major bug in PCHReader::ReadSelectorBlock().Steve Naroff
Also simplify some syntax in PCHWriter::WritePreprocessor(), suggested by Chris. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70039 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25Add new checker-specific attribute 'objc_ownership_retain'. This isn't hooked upTed Kremenek
to the checker yet, but essentially it allows a user to specify that an Objective-C method or C function increments the reference count of a passed object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70005 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24Add new checker-specific attribute 'objc_ownership_returns'. This isn't hookedTed Kremenek
up to the checker yet, but essentially it allows a user to specify that an Objective-C method or C function returns an owned an Objective-C object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70001 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24Fix two small but very nasty bugs in the PCH writer for method pools:Douglas Gregor
(1) Make sure to pad on-disk hash tables with 4 bytes, not 2, since the reader assumes that bucket data is aligned on 4-byte boundaries. (2) Don't emit the number of factory methods twice. This was throwing off the data counts and therefore causing lookups to fail. I've added asserts so that this class of error cannot happen again. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24PCH support for the global method pool (= instance and factory methodDouglas Gregor
pools, combined). The methods in the global method pool are lazily loaded from an on-disk hash table when Sema looks into its version of the hash tables. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69989 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24Add PCH support for #import.Steve Naroff
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24Eliminate Sema::ObjCImplementations, relying instead on name lookup. What's ↵Douglas Gregor
good for uniformity is good for PCH (or is it the other way around?). As part of this, make ObjCImplDecl inherit from NamedDecl (since ObjCImplementationDecls now need to have names so that they can be found). This brings ObjCImplDecl very, very close to ObjCContainerDecl; we may be able to merge them soon. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69941 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23Eliminate Sema::ObjCProtocols. Instead, we place ObjCProtocolDecls inDouglas Gregor
their own namespace (IDNS_Protocol) and use the normal name-lookup routines to find them. Aside from the simplification this provides (one less DenseMap!), it means that protocols will be lazily deserialized from PCH files. Make the code size of the selector table block match the code size of the type and decl blocks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69939 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23PCH support for categories in Objective-C interfaces.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69933 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23PCH support for all of the predefined Objective-C types, such as id,Douglas Gregor
SEL, Class, Protocol, CFConstantString, and __objcFastEnumerationState. With this, we can now run the Objective-C methods and properties PCH tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69932 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23Fix handling of C99 "extern inline" semantics when dealing withDouglas Gregor
multiple declarations of the function. Should fix PR3989 and <rdar://problem/6818429>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69905 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23Add PCH read/write support for Objective-C Selectors.Steve Naroff
Note: This support is non-lazy. Once we get "Cocoa.h" humming, we can optimize this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69884 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23PCH (de-)serialization of the protocols in an ObjCInterfaceDeclDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69860 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23PCH support for ObjCPropertyImplDeclDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69858 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23The ivars in an ObjCImplementationDecl are now stored in theDouglas Gregor
DeclContext rather than in a separate list. This makes PCH (de-)serialization trivial, so that ivars can be loaded lazily. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69857 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23PCH support for ObjCCategoryImplDecl (which can't be tested now).Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69856 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23PCH (de-)serialization for ObjCImplDecl. This can't be tested yet.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69855 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22PCH support for Objective-C property declarations (UNTESTED!)Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69843 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22Add PCH statistics for the number/percent of lexical/visible declcontexts readDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69835 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22Support locally-declared external declarations in PCH filesDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69833 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22Support tentative definitions in precompiled headers. This isn't likelyDouglas Gregor
to happen (ever), but at least we'll do the right thing when it does. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69829 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22Minimize the number and kind of "external definitions" that the PCHDouglas Gregor
file needs to store. CodeGen needs to see these definitions (via HandleTopLevelDecl), otherwise it won't be able to generate code for them. This patch notifies the consumer (e.g., CodeGen) about function definitions and variable definitions when the corresponding declarations are deserialized. Hence, we don't eagerly deserialize the declarations for every variable or function that has a definition in the PCH file. This gives another 5% speedup for the Carbon-prefixed "Hello, World!", and brings our PCH statistics down to something far more reasonable: *** PCH Statistics: 13/20693 types read (0.062823%) 17/59230 declarations read (0.028702%) 54/44914 identifiers read (0.120230%) 0/32954 statements read (0.000000%) 5/6187 macros read (0.080815%) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69820 91177308-0d34-0410-b5e6-96231b3b80d8