summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprAgg.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Simplify mem{cpy, move, set} creation with IRBuilder.Benjamin Kramer2010-12-301-12/+5
| | | | llvm-svn: 122634
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-3/+3
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* __block variables require us to evaluate the RHS of an assignment beforeJohn McCall2010-12-061-0/+2
| | | | | | | | | | the LHS, or else the pointer might be invalid. This is kindof dumb, but go ahead and make sure we're doing that for l-value scalar assignment, which fixes a miscompile of obj-c++.dg/block-seq.mm. Leave a FIXME for how to solve this problem for agg __blocks. llvm-svn: 120992
* Fix a bug in the emission of __real/__imag l-values on scalar operands.John McCall2010-12-051-2/+2
| | | | | | | | | Fix a bug in the emission of complex compound assignment l-values. Introduce a method to emit an expression whose value isn't relevant. Make that method evaluate its operand as an l-value if it is one. Fixes our volatile compliance in C++. llvm-svn: 120931
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-4/+11
| | | | | | | | | | | | | | | | | | | not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
* Kill the KVC l-value kind and calculate the base expression when emittingJohn McCall2010-12-041-6/+3
| | | | | | the l-value. llvm-svn: 120884
* Reflow to a style doug prefers, increasing indentation :-)Chris Lattner2010-12-021-24/+24
| | | | llvm-svn: 120746
* fix PR8726 by teaching the aggregate init optimization code to handle Chris Lattner2010-12-021-0/+33
| | | | | | structs with references in them correctly. llvm-svn: 120722
* Improve codegen for initializer lists to use memset more aggressivelyChris Lattner2010-12-021-12/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when an initializer is variable (I handled the constant case in a previous patch). This has three pieces: 1. Enhance AggValueSlot to have a 'isZeroed' bit to tell CGExprAgg that the memory being stored into has previously been memset to zero. 2. Teach CGExprAgg to not emit stores of zero to isZeroed memory. 3. Teach CodeGenFunction::EmitAggExpr to scan initializers to determine whether they are profitable to emit a memset + inividual stores vs stores for everything. The heuristic used is that a global has to be more than 16 bytes and has to be 3/4 zero to be candidate for this xform. The two testcases are illustrative of the scenarios this catches. We now codegen test9 into: call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 400, i32 4, i1 false) %.array = getelementptr inbounds [100 x i32]* %Arr, i32 0, i32 0 %tmp = load i32* %X.addr, align 4 store i32 %tmp, i32* %.array and test10 into: call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 392, i32 8, i1 false) %tmp = getelementptr inbounds %struct.b* %S, i32 0, i32 0 %tmp1 = getelementptr inbounds %struct.a* %tmp, i32 0, i32 0 %tmp2 = load i32* %X.addr, align 4 store i32 %tmp2, i32* %tmp1, align 4 %tmp5 = getelementptr inbounds %struct.b* %S, i32 0, i32 3 %tmp10 = getelementptr inbounds %struct.a* %tmp5, i32 0, i32 4 %tmp11 = load i32* %X.addr, align 4 store i32 %tmp11, i32* %tmp10, align 4 Previously we produced 99 stores of zero for test9 and also tons for test10. This xforms should substantially speed up -O0 builds when it kicks in as well as reducing code size and optimizer heartburn on insane cases. This resolves PR279. llvm-svn: 120692
* Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ↵John McCall2010-12-021-7/+0
| | | | | | | | ObjCPropertyRefExpr into the latter. llvm-svn: 120643
* Restore the lvalue-to-rvalue conversion patch with a minimal fix.John McCall2010-12-011-4/+38
| | | | llvm-svn: 120555
* L-value to r-value conversion is not ready for prime-time.John McCall2010-11-301-38/+4
| | | | llvm-svn: 120433
* Introduce an r-value to l-value cast kind. I'm not promising anythingJohn McCall2010-11-301-4/+38
| | | | | | about the reliability of this yet. llvm-svn: 120422
* Reset the lifetime-managed flag between emission of the agg conditionalJohn McCall2010-11-171-2/+8
| | | | | | branches. Fixes PR8623. llvm-svn: 119408
* Kill CK_Unknown and flesh out the documentation for the existing CastKinds.John McCall2010-11-161-2/+0
| | | | llvm-svn: 119331
* After discussion with Doug and John, I am revertingFariborz Jahanian2010-10-221-18/+1
| | | | | | the patch. llvm-svn: 117159
* Patch fixes miscompile with non-trivial copy constructors and Fariborz Jahanian2010-10-221-1/+18
| | | | | | statement expressions, //rdar: //8540501 llvm-svn: 117146
* Revert the hack Chris Lattner added in r97981 to work aroundDouglas Gregor2010-10-081-10/+0
| | | | | | | brokenness in the designated-initializer ASTs. The ASTs were fixed by Alp Toker's patch (r116098) for PR6955. Fixes PR6537. llvm-svn: 116101
* Initialize AggValueSlot's flags along all paths, plus minor beautification.John McCall2010-09-161-3/+3
| | | | | | Prospective fix for broken commit in r114045. llvm-svn: 114060
* Patch to move RequiresGCollection bit toFariborz Jahanian2010-09-161-13/+12
| | | | | | AggValueSlot slot. llvm-svn: 114045
* one piece of code is responsible for the lifetime of every aggregateJohn McCall2010-09-151-87/+70
| | | | | | | | | | | | | slot. The easiest way to do that was to bundle up the information we care about for aggregate slots into a new structure which demands that its creators at least consider the question. I could probably be convinced that the ObjC 'needs GC' bit should be rolled into this structure. Implement generalized copy elision. The main obstacle here is that IR-generation must be much more careful about making sure that exactly llvm-svn: 113962
* move the hackaround for PR6537 to catch unions as well,Chris Lattner2010-09-061-12/+12
| | | | | | fixing the ICE in PR7151 llvm-svn: 113130
* clean up some formatting.Chris Lattner2010-09-061-2/+1
| | | | llvm-svn: 113129
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-13/+12
| | | | | | to the new constants. llvm-svn: 112047
* Expression statements undergo lvalue-to-rvalue conversion in C,John McCall2010-08-251-2/+10
| | | | | | | | but not in C++, so don't emit aggregate loads of volatile references in null context in C++. Happens to have been caught by an assertion. We do not get the scalar case right. Volatiles are really broken. llvm-svn: 112019
* When performing value-initialization for a class with a non-trivial,Douglas Gregor2010-08-221-4/+0
| | | | | | | | | | | | implicitly-defined default constructor, zero-initialize the memory before calling the default constructor. Previously, we would only zero-initialize in the case of a trivial default constructor. Also, simplify the hideous logic that determines when we have a trivial default constructor and, therefore, don't need to emit any call at all. llvm-svn: 111779
* Experiment with using first-class aggregates to represent member functionJohn McCall2010-08-221-55/+0
| | | | | | | | | | pointers. I find the resulting code to be substantially cleaner, and it makes it very easy to use the same APIs for data member pointers (which I have conscientiously avoided here), and it avoids a plethora of potential inefficiencies due to excessive memory copying, but we'll have to see if it actually works. llvm-svn: 111776
* Abstract out member-pointer creation. I'm really unhappy about the currentJohn McCall2010-08-221-16/+4
| | | | | | | | duplication between the constant and non-constant paths in all of this. Implement ARM ABI semantics for member pointer constants and conversion. llvm-svn: 111772
* Abstract more member-pointerness out.John McCall2010-08-221-11/+5
| | | | llvm-svn: 111771
* Abstract out member-pointer conversions.John McCall2010-08-221-33/+9
| | | | | | Pretty much everything having to do with member pointers is ABI-specific. llvm-svn: 111770
* IRgen/LValue: Add LValue::setNonGC instead of SetObjCNonGC, for consistency ↵Daniel Dunbar2010-08-211-1/+1
| | | | | | with isNonGC(). llvm-svn: 111718
* IRgen: Switch more MakeAddr() users to MakeAddrLValue; this time for calls ↵Daniel Dunbar2010-08-211-18/+15
| | | | | | which were previously not computing the qualifier list. In most cases, I don't think it matters, but I believe this is conservatively more correct / consistent. llvm-svn: 111717
* IRgen: Switch a bunch of trivial MakeAddr calls to use MakeAddrLValue.Daniel Dunbar2010-08-211-6/+4
| | | | llvm-svn: 111716
* Store inheritance paths after CastExprs instead of inside them.John McCall2010-08-071-1/+3
| | | | | | | | | | | | | | | This takes some trickery since CastExpr has subclasses (and indeed, is abstract). Also, smoosh the CastKind into the bitfield from Expr. Drops two words of storage from Expr in the common case of expressions which don't need inheritance paths. Avoids a separate allocation and another word of overhead in cases needing inheritance paths. Also has the advantage of not leaking memory, since destructors for AST nodes are never run. llvm-svn: 110507
* Introduce a new cast kind for an "lvalue bitcast", which handlesDouglas Gregor2010-07-131-0/+4
| | | | | | | | | | | | | | | | 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-2/+2
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* fix the clang side of PR7437: EmitAggregateCopyChris Lattner2010-07-081-15/+8
| | | | | | | | | | | was not producing a memcpy with the right address spaces because of two places in it doing casts of the arguments to i8, one of which that didn't preserve the address space. There is also an optimizer bug here. llvm-svn: 107842
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-2/+2
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor2010-07-071-2/+2
| | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* misc tidyingChris Lattner2010-06-271-3/+1
| | | | llvm-svn: 106978
* finally get around to doing a significant cleanup to irgen:Chris Lattner2010-06-271-6/+3
| | | | | | | | 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
* Change EmitReferenceBindingToExpr to take a decl instead of a boolean.Anders Carlsson2010-06-261-1/+1
| | | | llvm-svn: 106949
* Patch adds support for copying of thoseFariborz Jahanian2010-06-151-5/+39
| | | | | | | | 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
* Fix for PR7040: Don't try to compute the LLVM type for a function where itEli Friedman2010-05-301-25/+1
| | | | | | | | | | | isn't possible to compute. This patch is mostly refactoring; the key change is the addition of the code starting with the comment, "Check whether the function has a computable LLVM signature." The solution here is essentially the same as the way the vtable code handles such functions. llvm-svn: 105151
* Re-teach IR gen to perform GC moves on rvalues resulting from various ObjCJohn McCall2010-05-221-17/+54
| | | | | | | expressions. Essentially, GC breaks a certain form of the return-value optimization. llvm-svn: 104454
* Re-land the fix for PR7139.Anders Carlsson2010-05-221-5/+1
| | | | llvm-svn: 104446
* Improve our handling of reference binding for subobjects ofDouglas Gregor2010-05-221-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Push a return-value slot throughout ObjC message-send codegen. Will beJohn McCall2010-05-221-7/+8
| | | | | | | critical for ObjC++ correctness; hard to test independently of various required Sema changes, though. llvm-svn: 104422
* Unbreak self-host.Anders Carlsson2010-05-211-1/+5
| | | | llvm-svn: 104390
OpenPOWER on IntegriCloud