summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Switch the destructor for a temporary arising from a reference binding over toJohn McCall2010-07-211-10/+2
| | | | | | using a lazy cleanup. llvm-svn: 108994
* Adopt objc_assign_threadlocal() for __thread variables of GC types.Fariborz Jahanian2010-07-201-3/+7
| | | | | | Implements radar 8203301. llvm-svn: 108917
* implement rdar://5739832 - operator new should check for overflow in multiply,Chris Lattner2010-07-201-3/+2
| | | | | | | | | | | | | | | | | | | | causing clang to compile this code into something that correctly throws a length error, fixing a potential integer overflow security attack: void *test(long N) { return new int[N]; } int main() { test(1L << 62); } We do this even when exceptions are disabled, because it is better for the code to abort than for the attack to succeed. This is heavily based on a patch that Fariborz wrote. llvm-svn: 108915
* Reinstate the scalar-cast-to-const-reference improvements, this timeDouglas Gregor2010-07-151-12/+43
| | | | | | | | | with the proper spelling of "non-class prvalue". Silly me, I think class rvalues were xvalues rather than prvalues! Hah hah hah. llvm-svn: 108443
* Revert r108431 and r108433 (the cast-to-const-reference fixes), whichDouglas Gregor2010-07-151-42/+12
| | | | | | broke nightlytest. llvm-svn: 108439
* Spell isPRValue() properly.Douglas Gregor2010-07-151-2/+1
| | | | llvm-svn: 108433
* Teach CodeGenFunction::EmitCastLValue() to handle casts to an lvalueDouglas Gregor2010-07-151-12/+43
| | | | | | | | that involve binding a reference to a pure rvalue temporary (e.g., not a class temporary), by creating a new temporary and copying the result there. Fixes PR6024. llvm-svn: 108431
* CK_BitCast is not an lvalue bitcast any longerDouglas Gregor2010-07-151-1/+0
| | | | llvm-svn: 108428
* Introduce a new cast kind for an "lvalue bitcast", which handlesDouglas Gregor2010-07-131-1/+2
| | | | | | | | | | | | | | | | reinterpret_casts (possibly indirectly via C-style/functional casts) on values, e.g., int i; reinterpret_cast<short&>(i); The IR generated for this is essentially the same as for *reinterpret_cast<short*>(&i). Fixes PR6437, PR7593, and PR7344. llvm-svn: 108294
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-3/+3
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-3/+3
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor2010-07-071-3/+3
| | | | | | newly-narrowed scope. No functionality change. llvm-svn: 107828
* Validated by nightly-test runs on x86 and x86-64 darwin, including afterJohn McCall2010-07-061-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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
* in the "coerce" case, the ABI handling code ends up making theChris Lattner2010-07-051-4/+4
| | | | | | | | | alloca for an argument. Make sure the argument gets the proper decl alignment, which may be different than the type alignment. This fixes PR7567 llvm-svn: 107627
* Remove unnecessary ASTContext parameter fromDouglas Gregor2010-07-011-1/+1
| | | | | | CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
* Correctly destroy reference temporaries with global storage. Remove ↵Anders Carlsson2010-06-271-9/+23
| | | | | | ErrorUnsupported call when binding a global reference to a non-lvalue. Fixes PR7326. llvm-svn: 106983
* Add a CreateReferenceTemporary that will do the right thing for variables ↵Anders Carlsson2010-06-271-6/+34
| | | | | | with global storage. llvm-svn: 106982
* Simplify CodeGenFunction::EmitReferenceBindingToExpr as a first step towards ↵Anders Carlsson2010-06-271-95/+90
| | | | | | fixing PR7326. llvm-svn: 106981
* Reduce indentation.Anders Carlsson2010-06-271-14/+11
| | | | llvm-svn: 106980
* finally get around to doing a significant cleanup to irgen:Chris Lattner2010-06-271-23/+12
| | | | | | | | have CGF create and make accessible standard int32,int64 and intptr types. This fixes a ton of 80 column violations introduced by LLVMContextification and cleans up stuff a lot. llvm-svn: 106977
* Implement rdar://7530813 - collapse multiple GEP instructions in IRgenChris Lattner2010-06-261-5/+40
| | | | | | | | | | | | | | | | | | | | This avoids generating two gep's for common array operations. Before we would generate something like: %tmp = load i32* %X.addr ; <i32> [#uses=1] %arraydecay = getelementptr inbounds [100 x i32]* %A, i32 0, i32 0 ; <i32*> [#uses=1] %arrayidx = getelementptr inbounds i32* %arraydecay, i32 %tmp ; <i32*> [#uses=1] %tmp1 = load i32* %arrayidx ; <i32> [#uses=1] Now we generate: %tmp = load i32* %X.addr ; <i32> [#uses=1] %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i32 %tmp ; <i32*> [#uses=1] %tmp1 = load i32* %arrayidx ; <i32> [#uses=1] Less IR is better at -O0. llvm-svn: 106966
* minor cleanup: don't emit the base of an array subscript until after Chris Lattner2010-06-261-8/+7
| | | | | | | we're done diddling around with the index stuff. Use a cheaper type comparison. llvm-svn: 106963
* move scalar inc/dec codegen into ScalarExprEmitter instead Chris Lattner2010-06-261-89/+0
| | | | | | of being in CGF. No functionality change. llvm-svn: 106961
* use more efficient type comparison predicates.Chris Lattner2010-06-261-1/+1
| | | | llvm-svn: 106958
* Change EmitReferenceBindingToExpr to take a decl instead of a boolean.Anders Carlsson2010-06-261-2/+5
| | | | llvm-svn: 106949
* Fix an Obj-C++ miscompile when calling an Obj-C method that returns a C++ ↵Anders Carlsson2010-06-211-3/+10
| | | | | | reference. llvm-svn: 106477
* objective-C++ IRGen: property reference as an Fariborz Jahanian2010-06-171-1/+9
| | | | | | | | lvalue when performing a derived-to-base conversion. Fixes radar 7501812. Added an executable test to llvm-test suite. llvm-svn: 106247
* Objective-c++ IRGen. Support for @selector expression asFariborz Jahanian2010-06-171-0/+8
| | | | | | an lvalue. Fixes PR7390. llvm-svn: 106235
* Move CodeGenOptions.h *back* into Frontend. This should have been done when theChandler Carruth2010-06-151-1/+1
| | | | | | dependency edge was reversed such that CodeGen depends on Frontend. llvm-svn: 106065
* Re-land the fix for PR7139.Anders Carlsson2010-05-221-1/+1
| | | | llvm-svn: 104446
* Improve our handling of reference binding for subobjects ofDouglas Gregor2010-05-221-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | temporaries. There are actually several interrelated fixes here: - When converting an object to a base class, it's only an lvalue cast when the original object was an lvalue and we aren't casting pointer-to-derived to pointer-to-base. Previously, we were misclassifying derived-to-base casts of class rvalues as lvalues, causing various oddities (including problems with reference binding not extending the lifetimes of some temporaries). - Teach the code for emitting a reference binding how to look through no-op casts and parentheses directly, since Expr::IgnoreParenNoOpCasts is just plain wrong for this. Also, make sure that we properly look through multiple levels of indirection from the temporary object, but destroy the actual temporary object; this fixes the reference-binding issue mentioned above. - Teach Objective-C message sends to bind the result as a temporary when needed. This is actually John's change, but it triggered the reference-binding problem above, so it's included here. Now John can actually test his return-slot improvements. llvm-svn: 104434
* Unbreak self-host.Anders Carlsson2010-05-211-1/+1
| | | | llvm-svn: 104390
* Rename CodeGenFunction::EmitMemSetToZero to EmitNullInitialization. Handle ↵Anders Carlsson2010-05-211-1/+1
| | | | | | setting null data member pointers correctly. Fixes PR7139. llvm-svn: 104387
* When emitting an lvalue for an anonymous struct or union member duringJohn McCall2010-05-211-0/+29
| | | | | | | class initialization, drill down through an arbitrary number of anonymous records. llvm-svn: 104310
* Rework our handling of binding a reference to a temporaryDouglas Gregor2010-05-201-18/+100
| | | | | | | | | | | | | | | | | | | | subobject. Previously, we could only properly bind to a base class subobject while extending the lifetime of the complete object (of a derived type); for non-static data member subobjects, we could memcpy (!) the result and bind to that, which is rather broken. Now, we pull apart the expression that we're binding to, to figure out which subobject we're accessing, then construct the temporary object (adding a destruction if needed) and, finally, dig out the subobject we actually meant to access. This fixes yet another instance where we were memcpy'ing rather than doing the right thing. However, note the FIXME in references.cpp: there's more work to be done for binding to subobjects, since the AST is incorrectly modeling some member accesses in base classes as lvalues when they are really rvalues. llvm-svn: 104219
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-4/+3
| | | | | | | | | | | | | | | | | | | | | 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
* Minor refactoring of my last patch.Fariborz Jahanian2010-05-111-4/+5
| | | | llvm-svn: 103475
* Objective-C++ Code gen. Handle code gen. for propertyFariborz Jahanian2010-05-101-1/+10
| | | | | | | reference dot-syntax notation in a varierty of cases. Fixes radar 7964490. llvm-svn: 103440
* Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.Anders Carlsson2010-05-021-0/+2
| | | | llvm-svn: 102882
* Change CodeGenFunction::GetAddressOfDerivedClass to take a BasePath.Anders Carlsson2010-04-241-7/+2
| | | | llvm-svn: 102273
* Convert more call sites over to the new GetAddressOfBaseClass.Anders Carlsson2010-04-241-10/+6
| | | | llvm-svn: 102272
* Handle compound assignment expressions (i += j) as lvalues, which isDouglas Gregor2010-04-231-0/+2
| | | | | | | permitted in C++ but not in C. Fixes PR6900. Clang can now handle all of Boost.Lambda's regression tests. llvm-svn: 102170
* Call PerformCopyInitialization to properly initialize the exception temporaryJohn McCall2010-04-221-0/+7
| | | | | | | | | in a throw expression. Use EmitAnyExprToMem to emit the throw expression, which magically elides the final copy-constructor call (which raises a new strict-compliance bug, but baby steps). Give __cxa_throw a destructor pointer if the exception type has a non-trivial destructor. llvm-svn: 102039
* Miscellaneous codegen cleanups. Mostly, don't create new basic blocksJohn McCall2010-04-211-6/+18
| | | | | | | just to save the current insertion state! This change significantly simplifies the IR CFG in exceptions code. llvm-svn: 101996
* Some renaming of methods, fixes typoFariborz Jahanian2010-04-191-2/+3
| | | | | | (related to PR6769). llvm-svn: 101794
* Local static variables must be available module-wiseFariborz Jahanian2010-04-181-0/+2
| | | | | | | as they are accessible in static methods in a class local to the same function. Fixes PR6769. llvm-svn: 101756
* Fix an assert when assigning a boolean value to a bitfield of type _Bool.Anders Carlsson2010-04-171-1/+5
| | | | llvm-svn: 101678
* IRgen: (Reapply 101222, with fixes) Move EmitStoreThroughBitfieldLValue to ↵Daniel Dunbar2010-04-151-88/+84
| | | | | | | | | | | | | | | | use new CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself. - Sadly, this doesn't seem to give any .ll size win so far. It is possible to make this routine significantly smarter & avoid various shifting, masking, and zext/sext, but I'm not really convinced it is worth it. It is tricky, and this is really instcombine's job. - No intended functionality change; the test case is just to increase coverage & serves as a demo file, it worked before this commit. The new fixes from r101222 are: 1. The shift to the target position needs to occur after the value is extended to the correct size. This broke Clang bootstrap, among other things no doubt. 2. Swap the order of arguments to OR, to get a tad more constant folding. llvm-svn: 101339
* Speculatively revert "IRgen: Move EmitStoreThroughBitfieldLValue to use new ↵Daniel Dunbar2010-04-141-82/+88
| | | | | | CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself.", I think it might be breaking bootstrap. llvm-svn: 101235
* IRgen: Move EmitStoreThroughBitfieldLValue to use new ↵Daniel Dunbar2010-04-141-88/+82
| | | | | | | | | | CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself. - Sadly, this doesn't seem to give any .ll size win so far. It is possible to make this routine significantly smarter & avoid various shifting, masking, and zext/sext, but I'm not really convinced it is worth it. It is tricky, and this is really instcombine's job. - No intended functionality change; the test case is just to increase coverage & serves as a demo file, it worked before this commit. llvm-svn: 101222
OpenPOWER on IntegriCloud