Commit Graph

125 Commits

Author SHA1 Message Date
Chris Lattner 487412d4db split decl reading out to its own PCHReaderDecl.cpp file.
llvm-svn: 70187
2009-04-27 05:27:42 +00:00
Chris Lattner 92ba5ffdfe split stmt/expr deserialization out to PCHReaderStmt.cpp
llvm-svn: 70186
2009-04-27 05:14:47 +00:00
Chris Lattner 6ab8142cb2 remove dead var
llvm-svn: 70174
2009-04-27 01:08:03 +00:00
Chris Lattner e78a6bec89 Set up DeclsCursor.
llvm-svn: 70173
2009-04-27 01:05:14 +00:00
Douglas Gregor 70091b8f43 Some fixes for PCH (de-)serialization of Objective-C AST nodes:
- 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.

llvm-svn: 70163
2009-04-26 22:20:50 +00:00
Chris Lattner 9356acecff Adjust to LLVM API changes that went into r70157.
llvm-svn: 70158
2009-04-26 20:59:20 +00:00
Steve Naroff eda6d20792 Add PCH read/write support for ObjC statements.
llvm-svn: 70143
2009-04-26 18:52:16 +00:00
Douglas Gregor 1970d887ab When writing a PCH file, write multiple type and declaration blocks as
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.

llvm-svn: 70109
2009-04-26 03:49:13 +00:00
Chris Lattner 7ec71da215 implement PCH support for the rest of ExprObjC.h, including
the missing bits of ObjCMessageExpr.

llvm-svn: 70100
2009-04-26 00:44:05 +00:00
Douglas Gregor eda6a89c4e Don't read all of the records in the PCH file's preprocessor block,
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.

llvm-svn: 70097
2009-04-26 00:07:37 +00:00
Douglas Gregor 99734e7669 Lazily load the controlling macros for all of the headers known in the
PCH file. In the Cocoa-prefixed "Hello, World" benchmark, this takes
us from reading 503 identifiers down to 37 and from 470 macros down to
4. It also results in an 8% performance improvement.

llvm-svn: 70094
2009-04-25 23:30:02 +00:00
Douglas Gregor 95272494cb Optimize the loading of an identifier from a PCH file when given the
identifier's ID. In this case, we know where the identifier's entry is
located in the hash table (it starts right before the identifier
string itself), so skip the hash table lookup and read the entry
directly. The performance improvement here is, gain, hard to quantify,
but it's the right thing to do.

llvm-svn: 70078
2009-04-25 21:21:38 +00:00
Douglas Gregor 5287b4e8ec PCH optimization for the identifier table, where we separate
"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.

llvm-svn: 70075
2009-04-25 21:04:17 +00:00
Douglas Gregor 6b7bf5a771 Revert my changes that try to avoid creating StringMap entries for
identifiers. They don't yet work, but will inhibit future
optimizations.

llvm-svn: 70071
2009-04-25 20:26:24 +00:00
Douglas Gregor 518bd14f2d Start implementing the PTH IdentifierInfo-saving trick in PCH,
allocating IdentifierInfos with a pointer into the string data stored
in the PCH file rather than having an entry in the identifier table's
string map. However, we don't actually get these savings at the
moment, because we go through the IdentifierTable when loading
identifiers from the on-disk hash table.

This commit is for record-keeping purposes only. I'll be reverting
this change (and the PCH layout tweak that preceded it) because it
appears that implementing this optimization will collide with another,
future optimization to reduce the size of the on-disk hash table for
identifiers. That optimization is likely to provide more benefit (with
less voodoo).

llvm-svn: 70070
2009-04-25 20:21:25 +00:00
Douglas Gregor b3e5f7a7ff Tweak the data layout for the on-disk hash table of identifiers in the PCH file so that the key layout matches that of the PTH key layout
llvm-svn: 70066
2009-04-25 19:25:49 +00:00
Douglas Gregor 0e14997758 Write the identifier offsets array into the PCH file as a blob, so
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.

llvm-svn: 70063
2009-04-25 19:10:14 +00:00
Douglas Gregor 745ed14636 Write the declaration and type offset arrays into the bitstream as
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!".

llvm-svn: 70059
2009-04-25 18:35:21 +00:00
Douglas Gregor 95c13f53b3 Load the selector table lazily from the PCH file.
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.

llvm-svn: 70055
2009-04-25 17:48:32 +00:00
Steve Naroff 62dccd01a2 Fix indexing error in PCHStmtReader::VisitArraySubscriptExpr().
llvm-svn: 70046
2009-04-25 15:19:54 +00:00
Steve Naroff eec4a0a7f1 Add PCH support for ObjCMessageExpr (needed to build Mail).
llvm-svn: 70044
2009-04-25 14:04:28 +00:00
Steve Naroff ac6e6f786b Fixup comment.
llvm-svn: 70040
2009-04-25 12:18:35 +00:00
Steve Naroff 4f2a71bcdb Fix a major bug in PCHReader::ReadSelectorBlock().
Also simplify some syntax in PCHWriter::WritePreprocessor(), suggested by Chris.

llvm-svn: 70039
2009-04-25 12:07:12 +00:00
Douglas Gregor f005eac566 Make sure that the consumer sees all interested decls. This fixes Preview
llvm-svn: 70007
2009-04-25 00:41:30 +00:00
Ted Kremenek 2cfd264636 Add new checker-specific attribute 'objc_ownership_retain'. This isn't hooked up
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.

llvm-svn: 70005
2009-04-25 00:17:17 +00:00
Douglas Gregor c62a133a38 When we de-serialize an Objective-C protocol, hand it to the AST consumer so that we can create metadata
llvm-svn: 70003
2009-04-24 23:42:14 +00:00
Ted Kremenek 44e662cd4f Add new checker-specific attribute 'objc_ownership_returns'. This isn't hooked
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.

llvm-svn: 70001
2009-04-24 23:09:54 +00:00
Douglas Gregor 6525578397 Once the protocol list has been loaded from the PCH file, add it to
the Objective-C interface.

llvm-svn: 69993
2009-04-24 22:01:00 +00:00
Douglas Gregor c78d34699f PCH support for the global method pool (= instance and factory method
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.

llvm-svn: 69989
2009-04-24 21:10:55 +00:00
Steve Naroff 3fa455a1aa Add PCH support for #import.
llvm-svn: 69987
2009-04-24 20:03:17 +00:00
Steve Naroff b87eeaeadf Use cast_or_null instead of ternary operator (suggested by Doug).
llvm-svn: 69975
2009-04-24 16:59:10 +00:00
Steve Naroff 54b6db1763 Allow the next catoregory slot to be null.
llvm-svn: 69969
2009-04-24 16:08:42 +00:00
Douglas Gregor 79947a24e6 Eliminate Sema::ObjCImplementations, relying instead on name lookup. What's 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.

llvm-svn: 69941
2009-04-24 00:11:27 +00:00
Douglas Gregor f6c2a27e16 PCH support for categories in Objective-C interfaces.
llvm-svn: 69933
2009-04-23 22:34:55 +00:00
Douglas Gregor 512b077803 PCH support for all of the predefined Objective-C types, such as id,
SEL, Class, Protocol, CFConstantString, and
__objcFastEnumerationState. With this, we can now run the Objective-C
methods and properties PCH tests.

llvm-svn: 69932
2009-04-23 22:29:11 +00:00
Douglas Gregor 89c8e000cf Fix handling of C99 "extern inline" semantics when dealing with
multiple declarations of the function. Should fix PR3989 and
<rdar://problem/6818429>.

llvm-svn: 69905
2009-04-23 18:22:55 +00:00
Steve Naroff 0cbba990d7 More PushOnScopeChain() FIXME's.
llvm-svn: 69894
2009-04-23 16:00:56 +00:00
Steve Naroff 3c301dc573 Sema::ActOnStartClassInterface(): Use PushOnScopeChains().
This enables class recognition to work with PCH. I believe this means we can remove Sema::ObjCInterfaceDecls and it's usage within Sema::LookupName(). Will investigate.

llvm-svn: 69891
2009-04-23 15:15:40 +00:00
Steve Naroff 2ddea05bca Add PCH read/write support for Objective-C Selectors.
Note: This support is non-lazy. Once we get "Cocoa.h" humming, we can optimize this.
llvm-svn: 69884
2009-04-23 10:39:46 +00:00
Douglas Gregor 515b505c3e PCH (de-)serialization of the protocols in an ObjCInterfaceDecl
llvm-svn: 69860
2009-04-23 03:59:07 +00:00
Douglas Gregor 0ebb9964f9 Add the PCH reader stub for ObjCCompatibleAliasDecl
llvm-svn: 69859
2009-04-23 03:51:49 +00:00
Douglas Gregor 49e72fb870 PCH support for ObjCPropertyImplDecl
llvm-svn: 69858
2009-04-23 03:43:53 +00:00
Douglas Gregor 5f66205233 The ivars in an ObjCImplementationDecl are now stored in the
DeclContext rather than in a separate list. This makes PCH
(de-)serialization trivial, so that ivars can be loaded lazily.

llvm-svn: 69857
2009-04-23 03:23:08 +00:00
Douglas Gregor 510fd8dff1 PCH support for ObjCCategoryImplDecl (which can't be tested now).
llvm-svn: 69856
2009-04-23 02:53:57 +00:00
Douglas Gregor 9a13efd5b2 PCH (de-)serialization for ObjCImplDecl. This can't be tested yet.
llvm-svn: 69855
2009-04-23 02:42:49 +00:00
Douglas Gregor 85e110828e PCH support for Objective-C property declarations (UNTESTED!)
llvm-svn: 69843
2009-04-22 23:20:34 +00:00
Douglas Gregor a57c3abf37 Add PCH statistics for the number/percent of lexical/visible declcontexts read
llvm-svn: 69835
2009-04-22 22:34:57 +00:00
Douglas Gregor acfc76cc63 Support locally-declared external declarations in PCH files
llvm-svn: 69833
2009-04-22 22:18:58 +00:00
Douglas Gregor d4df8657b4 Support tentative definitions in precompiled headers. This isn't likely
to happen (ever), but at least we'll do the right thing when it does.

llvm-svn: 69829
2009-04-22 22:02:47 +00:00
Douglas Gregor 7cd60f7be3 Eliminate some FIXMEs in the PCH reader that were either already fixed or aren't actually things to fix
llvm-svn: 69827
2009-04-22 21:15:06 +00:00