summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprAgg.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+3
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* Emit partial destruction of structs with initializer lists.John McCall2011-07-111-20/+47
| | | | llvm-svn: 134913
* Fix a lot of problems with the partial destruction of arrays:John McCall2011-07-111-12/+15
| | | | | | | | | | | - an off-by-one error in emission of irregular array limits for InitListExprs - use an EH partial-destruction cleanup within the normal array-destruction cleanup - get the branch destinations right for the empty check Also some refactoring which unfortunately obscures these changes. llvm-svn: 134890
* A number of array-related IR-gen cleanups.John McCall2011-07-091-36/+123
| | | | | | | | | | | | - Emit default-initialization of arrays that were partially initialized with initializer lists with a loop, rather than emitting the default initializer N times; - support destroying VLAs of non-trivial type, although this is not yet exposed to users; and - support the partial destruction of arrays initialized with initializer lists when an initializer throws an exception. llvm-svn: 134784
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-0/+1
| | | | | | | | | | | | where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 llvm-svn: 134605
* LValue carries a type now, so simplify the main EmitLoad/Store APIsJohn McCall2011-06-251-3/+3
| | | | | | by removing the redundant type parameter. llvm-svn: 133860
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* When emitting a compound literal of POD type, continue to emit aDouglas Gregor2011-06-171-0/+10
| | | | | | | | | | | | | | | | | separate aggregate temporary and then memcpy it over to the destination. This fixes a regression I introduced with r133235, where the compound literal on the RHS of an assignment makes use of the structure on the LHS of the assignment. I'm deeply suspicious of AggExprEmitter::VisitBinAssign()'s optimization where it emits the RHS of an aggregate assignment directly into the LHS lvalue without checking whether there is any aliasing between the LHS/RHS. However, I'm not in a position to revisit this now. Big thanks to Eli for finding the regression! llvm-svn: 133261
* Implement proper support for generating code for compound literals inDouglas Gregor2011-06-171-3/+8
| | | | | | | | | | | | | C++, which means: - binding the temporary as needed in Sema, so that we generate the appropriate call to the destructor, and - emitting the compound literal into the appropriate location for the aggregate, rather than trying to emit it as a temporary and memcpy() it. Fixes PR10138 / <rdar://problem/9615901>. llvm-svn: 133235
* Restore correct use of GC barriers.John McCall2011-06-161-33/+32
| | | | llvm-svn: 133144
* Automatic Reference Counting.John McCall2011-06-151-8/+16
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-1/+1
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* removes a meaningless comment.Fariborz Jahanian2011-04-291-3/+1
| | | | llvm-svn: 130550
* block variables on lhs need be ir-gen'ed after theFariborz Jahanian2011-04-291-1/+18
| | | | | | | | rhs when its 'forwarding' pointer may be modified in rhs evaluation as result of call to Block_copy. // rdar://9309454 llvm-svn: 130545
* Cut down unnecessary zero'ing when value-initializing arrays of C++ objects.Argyrios Kyrtzidis2011-04-281-1/+10
| | | | | | | -C++ objects with user-declared constructor don't need zero'ing. -We can zero-initialize arrays of C++ objects in "bulk" now, in which case don't zero-initialize each object again. llvm-svn: 130453
* Get the base element type even in multidimensional arrays.Argyrios Kyrtzidis2011-04-281-1/+2
| | | | llvm-svn: 130427
* When value-initializing the elements of an array not not included in the ↵Argyrios Kyrtzidis2011-04-281-1/+9
| | | | | | | | | | initializer make sure that a non-trivial C++ constructor gets called. Fixes rdar://9347552 & http://llvm.org/PR9801 llvm-svn: 130421
* Convert size and alignment variables to CharUnits in EmitAggregateCopy(). NoKen Dyck2011-04-241-7/+10
| | | | | | change in functionality intended. llvm-svn: 130113
* Convert type size and alignment to CharUnits in CheckAggExprForMemSetUse().Ken Dyck2011-04-241-8/+9
| | | | | | No change in functionality intended. llvm-svn: 130112
* Convert the return type of GetNumNonZeroBytesInInit() to CharUnits. NoKen Dyck2011-04-241-7/+8
| | | | | | change in functionality intended. llvm-svn: 130111
* Eliminate some literal 8s by converting size variables in EmitGCMove() andKen Dyck2011-04-241-4/+4
| | | | | | EmitFinalDestCopy() to CharUnits. No change in functionality intended. llvm-svn: 130110
* Replace calls to ASTContext::getTypeInfo() with calls toKen Dyck2011-04-241-6/+2
| | | | | | | ASTContext::getTypeSize() when only the size part is used. No change in functionality intended. llvm-svn: 130109
* ForArgyrios Kyrtzidis2011-04-211-0/+2
| | | | | | | | | | | | | | double data[20000000] = {0}; we would blow out the memory by creating 20M Exprs to fill out the initializer. To fix this, if the initializer list initializes an array with more elements than there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression that specifies an expression to be used for value initialization of the rest of the elements. Fixes rdar://9275920. llvm-svn: 129896
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-5/+6
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* We can't emit an aggregate cast as its sub-expression in general justJohn McCall2011-04-121-5/+2
| | | | | | | | | because the result is ignored. The particular example here is with property l-values, but there could be all sorts of lovely casts that this isn't safe for. Sink the check into the one case that seems to actually be capable of honoring this. llvm-svn: 129397
* After some discussion with Doug, we decided that it made a lot more senseJohn McCall2011-04-121-5/+0
| | | | | | | | | for __unknown_anytype resolution to destructively modify the AST. So that's what it does now, which significantly simplifies some of the implementation. Normal member calls work pretty cleanly now, and I added support for propagating unknown-ness through &. llvm-svn: 129331
* More __unknown_anytype work.John McCall2011-04-111-0/+1
| | | | llvm-svn: 129269
* Remove CK_DynamicToNull.Anders Carlsson2011-04-111-4/+1
| | | | llvm-svn: 129265
* As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind whichAnders Carlsson2011-04-101-1/+4
| | | | | | | | | | | | | | | | | | represents a dynamic cast where we know that the result is always null. For example: struct A { virtual ~A(); }; struct B final : A { }; struct C { }; bool f(B* b) { return dynamic_cast<C*>(b); } llvm-svn: 129256
* Basic, untested implementation for an "unknown any" type requested by LLDB.John McCall2011-04-071-0/+4
| | | | | | | | | | | | The idea is that you can create a VarDecl with an unknown type, or a FunctionDecl with an unknown return type, and it will still be valid to access that object as long as you explicitly cast it at every use. I'm still going back and forth about how I want to test this effectively, but I wanted to go ahead and provide a skeletal implementation for the LLDB folks' benefit and because it also improves some diagnostic goodness for placeholder expressions. llvm-svn: 129065
* Fix IRGen issues related to using property-dot syntaxFariborz Jahanian2011-03-301-3/+11
| | | | | | for prperty reference types. // rdar://9208606. llvm-svn: 128551
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-171-10/+9
| | | | | | | | | | | | | | | | | | | | | | 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
* Save a copy expression for non-trivial copy constructions of catch variables.John McCall2011-02-161-0/+6
| | | | llvm-svn: 125661
* Reorganize CodeGen{Function,Module} to eliminate the unfortunateJohn McCall2011-02-081-2/+2
| | | | | | | | Block{Function,Module} base class. Minor other refactorings. Fixed a few address-space bugs while I was there. llvm-svn: 125085
* Better framework for conditional cleanups; untested as yet.John McCall2011-01-261-10/+10
| | | | | | | | 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
* Ensure an insertion point at the end of a statement-expression.John McCall2011-01-131-0/+1
| | | | | | Fixes PR8967. llvm-svn: 123360
* 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
OpenPOWER on IntegriCloud