summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExprAgg.cpp
AgeCommit message (Collapse)Author
2011-03-30Fix IRGen issues related to using property-dot syntaxFariborz Jahanian
for prperty reference types. // rdar://9208606. llvm-svn: 128551
2011-02-17Change the representation of GNU ?: expressions to use a different expressionJohn McCall
class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
2011-02-16Save a copy expression for non-trivial copy constructions of catch variables.John McCall
llvm-svn: 125661
2011-02-08Reorganize CodeGen{Function,Module} to eliminate the unfortunateJohn McCall
Block{Function,Module} base class. Minor other refactorings. Fixed a few address-space bugs while I was there. llvm-svn: 125085
2011-01-26Better framework for conditional cleanups; untested as yet.John McCall
I'm separately committing this because it incidentally changes some block orderings and minor IR issues, like using a phi instead of an unnecessary alloca. llvm-svn: 124277
2011-01-13Ensure an insertion point at the end of a statement-expression.John McCall
Fixes PR8967. llvm-svn: 123360
2010-12-30Simplify mem{cpy, move, set} creation with IRBuilder.Benjamin Kramer
llvm-svn: 122634
2010-12-06Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall
reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
2010-12-06__block variables require us to evaluate the RHS of an assignment beforeJohn McCall
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
2010-12-05Fix a bug in the emission of __real/__imag l-values on scalar operands.John McCall
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
2010-12-04Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall
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
2010-12-04Kill the KVC l-value kind and calculate the base expression when emittingJohn McCall
the l-value. llvm-svn: 120884
2010-12-02Reflow to a style doug prefers, increasing indentation :-)Chris Lattner
llvm-svn: 120746
2010-12-02fix PR8726 by teaching the aggregate init optimization code to handle Chris Lattner
structs with references in them correctly. llvm-svn: 120722
2010-12-02Improve codegen for initializer lists to use memset more aggressivelyChris Lattner
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
2010-12-02Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ↵John McCall
ObjCPropertyRefExpr into the latter. llvm-svn: 120643
2010-12-01Restore the lvalue-to-rvalue conversion patch with a minimal fix.John McCall
llvm-svn: 120555
2010-11-30L-value to r-value conversion is not ready for prime-time.John McCall
llvm-svn: 120433
2010-11-30Introduce an r-value to l-value cast kind. I'm not promising anythingJohn McCall
about the reliability of this yet. llvm-svn: 120422
2010-11-17Reset the lifetime-managed flag between emission of the agg conditionalJohn McCall
branches. Fixes PR8623. llvm-svn: 119408
2010-11-16Kill CK_Unknown and flesh out the documentation for the existing CastKinds.John McCall
llvm-svn: 119331
2010-10-22After discussion with Doug and John, I am revertingFariborz Jahanian
the patch. llvm-svn: 117159
2010-10-22Patch fixes miscompile with non-trivial copy constructors and Fariborz Jahanian
statement expressions, //rdar: //8540501 llvm-svn: 117146
2010-10-08Revert the hack Chris Lattner added in r97981 to work aroundDouglas Gregor
brokenness in the designated-initializer ASTs. The ASTs were fixed by Alp Toker's patch (r116098) for PR6955. Fixes PR6537. llvm-svn: 116101
2010-09-16Initialize AggValueSlot's flags along all paths, plus minor beautification.John McCall
Prospective fix for broken commit in r114045. llvm-svn: 114060
2010-09-16Patch to move RequiresGCollection bit toFariborz Jahanian
AggValueSlot slot. llvm-svn: 114045
2010-09-15one piece of code is responsible for the lifetime of every aggregateJohn McCall
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
2010-09-06move the hackaround for PR6537 to catch unions as well,Chris Lattner
fixing the ICE in PR7151 llvm-svn: 113130
2010-09-06clean up some formatting.Chris Lattner
llvm-svn: 113129
2010-08-25GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall
to the new constants. llvm-svn: 112047
2010-08-25Expression statements undergo lvalue-to-rvalue conversion in C,John McCall
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
2010-08-22When performing value-initialization for a class with a non-trivial,Douglas Gregor
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
2010-08-22Experiment with using first-class aggregates to represent member functionJohn McCall
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
2010-08-22Abstract out member-pointer creation. I'm really unhappy about the currentJohn McCall
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
2010-08-22Abstract more member-pointerness out.John McCall
llvm-svn: 111771
2010-08-22Abstract out member-pointer conversions.John McCall
Pretty much everything having to do with member pointers is ABI-specific. llvm-svn: 111770
2010-08-21IRgen/LValue: Add LValue::setNonGC instead of SetObjCNonGC, for consistency ↵Daniel Dunbar
with isNonGC(). llvm-svn: 111718
2010-08-21IRgen: Switch more MakeAddr() users to MakeAddrLValue; this time for calls ↵Daniel Dunbar
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
2010-08-21IRgen: Switch a bunch of trivial MakeAddr calls to use MakeAddrLValue.Daniel Dunbar
llvm-svn: 111716
2010-08-07Store inheritance paths after CastExprs instead of inside them.John McCall
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
2010-07-13Introduce a new cast kind for an "lvalue bitcast", which handlesDouglas Gregor
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
2010-07-08Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor
suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
2010-07-08fix the clang side of PR7437: EmitAggregateCopyChris Lattner
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
2010-07-07Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor
breaking bootstrap on Linux. llvm-svn: 107837
2010-07-07Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor
newly-narrowed scope. No functionality change. llvm-svn: 107828
2010-07-06Validated by nightly-test runs on x86 and x86-64 darwin, including afterJohn McCall
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
2010-06-27misc tidyingChris Lattner
llvm-svn: 106978
2010-06-27finally get around to doing a significant cleanup to irgen:Chris Lattner
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
2010-06-26Change EmitReferenceBindingToExpr to take a decl instead of a boolean.Anders Carlsson
llvm-svn: 106949
2010-06-15Patch adds support for copying of thoseFariborz Jahanian
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