summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjCGNU.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r128156 because of CodeGenObjC/messages.m and Coverage/codegen-gnu.m.Andrew Trick2011-03-231-9/+10
| | | | llvm-svn: 128157
* Remove the redundant loads / stores to globals that we were generating for ↵David Chisnall2011-03-231-10/+9
| | | | | | selectors (GNU runtimes). llvm-svn: 128156
* Initial work on refactoring GNU runtime code (long overdue - it's quite obviousDavid Chisnall2011-03-231-298/+349
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that I hadn't used C++ for several years before writing most of this code). Still lots more to do. This set of changes includes: - Remove the distinction between typed and untyped selectors. More accurately reflect what the runtime does, by using typed selectors everywhere, with an empty type field if the types are unknown. Now we just store a small list of types for each selector (in theory, this should always be exactly one, but this constraint was not enforced back in 1986 when it should have been). - Add some consistency to how runtime functions are created. These are all generated via the LazyRuntimeFunction class (which might be useful outside CGObjCGNU - feel free to move it into a header if it is). This function stores the types of a function, looks it up the first time it's used, and caches the result. This means that we're now not wasting time constructing the llvm::FunctionType every time some of the functions are looked up, but also not inserting references to runtime functions into the module if they're not actually used. - Started separating out the fragile and non-fragile ABI behaviours into two subclasses of CGObjCGNU: CGObjCGCC for the legacy GCC runtime ABI and CGObjCGNUstep for the new GNUstep ABI. Not all of the differences in behaviour are factored out yet, but they will be in future commits. - Removed all of the CodeGen:: things: we've been using namespace CodeGen in this file for ages, so having explicit namespace specifiers is just a bit confusing. - Added a few more comments. - Used llvm::StringRef instead of std::string in a few places. - Finally got around to storing the module path in the module structure. The ABI says that the compiler should do this, although it's not used in the runtime or exposed outside the runtime, so it's pretty useless. Still to do: - We currently have two code paths for generating try blocks, one for ObjC and one for ObjC++. Not only are these substantially similar, they are also very similar to the CGObjCMac version. These need factoring out into a single parameterised implementation, either in CGObjCRuntime or CodeGenFunction. The EmitObjCXXTryStmt() function was added so that the changes to fix a bug in time for the 2.9 release would be self-contained and reduce the chances of breaking anything else, but these should be done properly as soon as possible. - Split up some large functions (e.g. GenerateClass()) into smaller functions for generating the various data structures. - The method lookup code into the two subclasses, removing the conditionals in the message send functions. - Add doxygen comments on the remaining undocumented functions. - We seem to be generating global pointer variables for selectors, then storing a pointer to the selector, then generating a load of this pointer (and then a load of the real selector later) every time a static selector is used. I can only assume I was asleep or drunk when I did this - we should just be referencing the selectors directly in the selector array. llvm-svn: 128152
* Make the ivar offset always be a ptrdiff_t, because stuff in CGObjC.cpp ↵David Chisnall2011-03-221-3/+5
| | | | | | expects this. Actually, it expects a long, but that's a bug that will be fixed in the next commit... llvm-svn: 128102
* Fix Objective-C++ exceptions (GNU runtime).David Chisnall2011-03-201-2/+197
| | | | llvm-svn: 127980
* Fix foreign exception handling (GNU runtime).David Chisnall2011-03-161-6/+17
| | | | llvm-svn: 127736
* Fix incorrect linkage specifiers for selectors.David Chisnall2011-03-141-2/+2
| | | | llvm-svn: 127580
* Fix type mismatch between property function that CGObjCGNU was returning and ↵David Chisnall2011-02-231-4/+4
| | | | | | the one CGObjC was calling. Fixes bug r9294. llvm-svn: 126312
* The instance size of a metaclass should be the size of a class. This is ↵David Chisnall2011-02-211-1/+6
| | | | | | not, in fact, 0, even for very small classes. (GNU runtime) llvm-svn: 126161
* Convert RecordLayout::Size to CharUnits from bits. No changes toKen Dyck2011-02-091-2/+3
| | | | | | functionality intended. llvm-svn: 125156
* A few more tweaks to the blocks AST representation: John McCall2011-02-071-2/+2
| | | | | | | | | | | | | | | | | - BlockDeclRefExprs always store VarDecls - BDREs no longer store copy expressions - BlockDecls now store a list of captured variables, information about how they're captured, and a copy expression if necessary With that in hand, change IR generation to use the captures data in blocks instead of walking the block independently. Additionally, optimize block layout by emitting fields in descending alignment order, with a heuristic for filling in words when alignment of the end of the block header is insufficient for the most aligned field. llvm-svn: 125005
* Move all the cleanups framework code into a single file.John McCall2011-01-281-1/+1
| | | | | | Pure motion. llvm-svn: 124484
* Add support for GNU runtime property set / get structure functions. Minor ↵David Chisnall2010-12-261-14/+39
| | | | | | refactoring of Mac runtime (returns the same function for both, as the Mac runtimes currently only provide a single entry point for setting and getting struct properties, although this will presumably be fixed at some point). llvm-svn: 122569
* Remove the use of aliases in outputted code from ObjC (GNU runtime).David Chisnall2010-11-091-4/+6
| | | | llvm-svn: 118498
* Some fixes for synthesized ivar metadata (GNU runtime).David Chisnall2010-11-031-12/+19
| | | | llvm-svn: 118172
* Death to blocks, or at least the word "block" in one particular obnoxiouslyJohn McCall2010-10-151-1/+1
| | | | | | ambiguous context. llvm-svn: 116567
* Fixes an obscure bug in importd block variable layoutFariborz Jahanian2010-09-111-1/+1
| | | | | | | | information when imported variable is used more than once. Originally though to be a bug in importing block varibles. Fixes radar 8417746. llvm-svn: 113675
* Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()Benjamin Kramer2010-08-171-1/+1
| | | | | | and remove getStrData(). Patch by Peter Davies (with some tweaks). llvm-svn: 111229
* Some early work for providing block layout info. Fariborz Jahanian2010-08-041-0/+4
| | | | | | for objective-c/c++ blocks (NeXt runtime). llvm-svn: 110213
* Support catching Objective C pointers in C++ under the non-fragile NeXT runtime.John McCall2010-07-241-0/+6
| | | | | | Diagnose attempts to do this under the GNU or fragile NeXT runtimes. llvm-svn: 109298
* Revise cleanup IR generation to fix a major bug with cleanups (PR7686)John McCall2010-07-231-7/+5
| | | | | | | as well as some significant asymptotic inefficiencies with threading multiple jumps through deep cleanups. llvm-svn: 109274
* Don't crash when sending a message inside a block with the non-fragile ABI ↵David Chisnall2010-07-211-1/+1
| | | | | | (GNU runtime). llvm-svn: 109012
* Mark the load after calling objc_msg_lookup_sender() so that it doesn't get ↵David Chisnall2010-07-211-2/+2
| | | | | | optimised away (GNU runtime). llvm-svn: 109010
* Rename LazyCleanup -> Cleanup. No functionality change for these last threeJohn McCall2010-07-211-3/+2
| | | | | | commits. llvm-svn: 109000
* Convert the ObjC @synchronized cleanups to laziness. This is not actuallyJohn McCall2010-07-211-7/+16
| | | | | | | a big deal, except that I want to eliminate the shared-code EH cleanups in preparation for a significant algorithmic fix. llvm-svn: 108973
* Adopt objc_assign_threadlocal() for __thread variables of GC types.Fariborz Jahanian2010-07-201-3/+9
| | | | | | Implements radar 8203301. llvm-svn: 108917
* Teach IR generation how to lazily emit cleanups. This has a lot of advantages,John McCall2010-07-131-2/+1
| | | | | | | | | | | | | | | mostly in avoiding unnecessary work at compile time but also in producing more sensible block orderings. Move the destructor cleanups for local variables over to use lazy cleanups. Eventually all cleanups will do this; for now we have some awkward code duplication. Tell IR generation just to never produce landing pads in -fno-exceptions. This is a much more comprehensive solution to a problem which previously was half-solved by checks in most cleanup-generation spots. llvm-svn: 108270
* Validated by nightly-test runs on x86 and x86-64 darwin, including afterJohn McCall2010-07-061-214/+140
| | | | | | | | | | | | | | | | | | | | | | | | self-host. Hopefully these results hold up on different platforms. I tried to keep the GNU ObjC runtime happy, but it's hard for me to test. Reimplement how clang generates IR for exceptions. Instead of creating new invoke destinations which sequentially chain to the previous destination, push a more semantic representation of *why* we need the cleanup/catch/filter behavior, then collect that information into a single landing pad upon request. Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional control flow) are generated, since it's actually fairly closely tied in with the former. Remove the need to track which cleanup scope a block is associated with. Document a lot of previously poorly-understood (by me, at least) behavior. The new framework implements the Horrible Hack (tm), which requires every landing pad to have a catch-all so that inlining will work. Clang no longer requires the Horrible Hack just to make exceptions flow correctly within a function, however. The HH is an unfortunate requirement of LLVM's EH IR. llvm-svn: 107631
* Objective-c++ IRGen. Support for @selector expression asFariborz Jahanian2010-06-171-3/+6
| | | | | | an lvalue. Fixes PR7390. llvm-svn: 106235
* Give Type::isIntegralType() an ASTContext parameter, so that itDouglas Gregor2010-06-161-2/+2
| | | | | | | | | | | | provides C "integer type" semantics in C and C++ "integral type" semantics in C++. Note that I still need to update isIntegerType (and possibly other predicates) using the same approach I've taken for isIntegralType(). The two should have the same meaning, but currently don't (!). llvm-svn: 106074
* Patch adds support for copying of thoseFariborz Jahanian2010-06-151-8/+3
| | | | | | | | objective-c++ class objects which have GC'able objc object pointers and need to use ObjC's objc_memmove_collectable API (radar 8070772). llvm-svn: 106061
* Push a return-value slot throughout ObjC message-send codegen. Will beJohn McCall2010-05-221-2/+6
| | | | | | | critical for ObjC++ correctness; hard to test independently of various required Sema changes, though. llvm-svn: 104422
* Fix my inability to spell 'continue' and a case where message sends ↵David Chisnall2010-05-201-4/+7
| | | | | | returning non-pointer-sized things were generating invalid IR inside @try blocks. llvm-svn: 104222
* Clean up some more uses of getAs<ObjCInterfaceType>() that Fariborz pointedJohn McCall2010-05-171-4/+4
| | | | | | out. The remaining ones are okay. llvm-svn: 103973
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-1/+2
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* Tweaked selector mangling again (GNU runtime).David Chisnall2010-05-091-6/+17
| | | | llvm-svn: 103368
* Fixed linkage problem from last commit (GNU runtime).David Chisnall2010-05-081-2/+2
| | | | llvm-svn: 103355
* Tweaked selector generation (GNU runtime). Removed the use of GlobalAliases ↵David Chisnall2010-05-081-9/+15
| | | | | | in the generated bitcode. llvm-svn: 103353
* As per Chris' request, return the Instruction from EmitCall and add the ↵David Chisnall2010-05-021-3/+8
| | | | | | metadata in the caller. llvm-svn: 102862
* Attach message send metadata to the lookup as well as to the call (GNU runtime).David Chisnall2010-05-011-7/+10
| | | | llvm-svn: 102839
* Make super message lookups cacheable (GNUstep Runtime)David Chisnall2010-05-011-14/+34
| | | | llvm-svn: 102837
* Tweaked EmitCall() to permit the caller to provide some metadata to attach ↵David Chisnall2010-05-011-9/+18
| | | | | | | | to the call site. Used this in CGObjCGNU to attach metadata about message sends to permit speculative inlining. llvm-svn: 102833
* Fixed incorrect type of alloca (GNU runtime).David Chisnall2010-04-301-2/+5
| | | | llvm-svn: 102711
* Changed signature of GenerateMessageSend() function to pass the ↵David Chisnall2010-04-281-4/+16
| | | | | | | | ObjCInterfaceDecl for class messages and removed the boolean IsClassMessage argument, which wasn't used anywhere. Emitted some metadata on message sends to allow a later pass to do some speculative inlining of class methods (GNU runtime). Speculative inlining of instance methods requires type feedback to be useful (work in progress), but for class methods it works quite nicely. llvm-svn: 102514
* Remove unused function.Benjamin Kramer2010-04-281-4/+0
| | | | llvm-svn: 102499
* Emit the correct symbol name for the class (GNU runtime).David Chisnall2010-04-281-5/+7
| | | | llvm-svn: 102497
* Fixed message send to void (broken by my last commit - GNU runtime).David Chisnall2010-04-271-1/+2
| | | | llvm-svn: 102459
* Ensure return from a message to nil is always 0 (GNU runtime).David Chisnall2010-04-271-1/+67
| | | | | | | | | This works around stack corruption / crashes resulting from PR6944, and also works around people who expect 'what works on my machine' to work everywhere (GCC crashes in a number of cases on SPARC that should now work correctly with clang). llvm-svn: 102430
* Make the static type of the exception variable in an Objective-CDouglas Gregor2010-04-261-3/+3
| | | | | | | @catch a VarDecl. The dynamic type is still a ParmVarDecl, but that will change soon. No effective functionality change. llvm-svn: 102341
* Improve the AST representation of Objective-C @try/@catch/@finallyDouglas Gregor2010-04-231-3/+4
| | | | | | | | | | statements. Instead of the @try having a single @catch, where all of the @catch's were chained (using an O(n^2) algorithm nonetheless), @try just holds an array of its @catch blocks. The resulting AST is slightly more compact (not important) and better represents the actual language semantics (good). llvm-svn: 102221
OpenPOWER on IntegriCloud