summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
AgeCommit message (Collapse)Author
2010-08-23Abstract out everything having to do with member pointers into the ABIJohn McCall
class; they should just be completely opaque throughout IR gen now, although I haven't really audited that. Fix a bug apparently inherited from gcc-4.2 where we failed to null-check member data pointers when performing derived-to-base or base-to-derived conversions on them. llvm-svn: 111789
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-22Extract member function pointer comparison and null comparison intoJohn McCall
the ABI code. Implement correct semantics for these on ARM. I believe this completes the implementation of member function pointers on ARM. I think I'm going to switch member function pointers over to be non-aggregates while I have all this in mind. llvm-svn: 111774
2010-08-21IRgen: Set the alignment correctly when creating LValue for a decls.Daniel Dunbar
- Fixes PR5598. - Review appreciated. llvm-svn: 111726
2010-08-21IRgen: Move remaining LValue::Set... methods to LValue::set... (non-static) ↵Daniel Dunbar
methods. llvm-svn: 111722
2010-08-21IRgen: Move remaining MakeAddr() calls to MakeAddrLValue().Daniel Dunbar
llvm-svn: 111721
2010-08-21IRgen: The CVR qualifiers in a subobject adjustment should just come from theDaniel Dunbar
field (I think). - Doug, please check. llvm-svn: 111720
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-21IRgen: Eliminate EmitPredefinedFunctionName(), it doesn't need to be ↵Daniel Dunbar
factored out. llvm-svn: 111715
2010-08-21IRgen/CGValue: Add alignment to LValue, and use that alignment when ↵Daniel Dunbar
generating lvalue load/stores. llvm-svn: 111710
2010-08-21IRgen: Change Emit{Load,Store}OfScalar to take a required Alignment argument andDaniel Dunbar
update callers as best I can. - This is a work in progress, our alignment handling is very horrible / sketchy -- I am just aiming for monotonic improvement. - Serious review appreciated. llvm-svn: 111707
2010-08-18fix typoChris Lattner
llvm-svn: 111334
2010-08-18Fix PR7889 by generalizing some over specialized code. There is noChris Lattner
reason that this should be limited to simple lvalues. llvm-svn: 111331
2010-08-17fix PR7892, a crash on valid in c++ codegen of __PRETTY_FUNCTION__Chris Lattner
llvm-svn: 111330
2010-08-07Allow reference binding of a reference of Objective-C object type toDouglas Gregor
an lvalue of another, compatible Objective-C object type (e.g., a subclass). Introduce a new initialization sequence step kind to describe this binding, along with a new cast kind. Fixes PR7741. llvm-svn: 110513
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-21Switch the destructor for a temporary arising from a reference binding over toJohn McCall
using a lazy cleanup. llvm-svn: 108994
2010-07-20Adopt objc_assign_threadlocal() for __thread variables of GC types.Fariborz Jahanian
Implements radar 8203301. llvm-svn: 108917
2010-07-20implement rdar://5739832 - operator new should check for overflow in multiply,Chris Lattner
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
2010-07-15Reinstate the scalar-cast-to-const-reference improvements, this timeDouglas Gregor
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
2010-07-15Revert r108431 and r108433 (the cast-to-const-reference fixes), whichDouglas Gregor
broke nightlytest. llvm-svn: 108439
2010-07-15Spell isPRValue() properly.Douglas Gregor
llvm-svn: 108433
2010-07-15Teach CodeGenFunction::EmitCastLValue() to handle casts to an lvalueDouglas Gregor
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
2010-07-15CK_BitCast is not an lvalue bitcast any longerDouglas Gregor
llvm-svn: 108428
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-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-07-05in the "coerce" case, the ABI handling code ends up making theChris Lattner
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
2010-07-01Remove unnecessary ASTContext parameter fromDouglas Gregor
CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
2010-06-27Correctly destroy reference temporaries with global storage. Remove ↵Anders Carlsson
ErrorUnsupported call when binding a global reference to a non-lvalue. Fixes PR7326. llvm-svn: 106983
2010-06-27Add a CreateReferenceTemporary that will do the right thing for variables ↵Anders Carlsson
with global storage. llvm-svn: 106982
2010-06-27Simplify CodeGenFunction::EmitReferenceBindingToExpr as a first step towards ↵Anders Carlsson
fixing PR7326. llvm-svn: 106981
2010-06-27Reduce indentation.Anders Carlsson
llvm-svn: 106980
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-26Implement rdar://7530813 - collapse multiple GEP instructions in IRgenChris Lattner
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
2010-06-26minor cleanup: don't emit the base of an array subscript until after Chris Lattner
we're done diddling around with the index stuff. Use a cheaper type comparison. llvm-svn: 106963
2010-06-26move scalar inc/dec codegen into ScalarExprEmitter instead Chris Lattner
of being in CGF. No functionality change. llvm-svn: 106961
2010-06-26use more efficient type comparison predicates.Chris Lattner
llvm-svn: 106958
2010-06-26Change EmitReferenceBindingToExpr to take a decl instead of a boolean.Anders Carlsson
llvm-svn: 106949
2010-06-21Fix an Obj-C++ miscompile when calling an Obj-C method that returns a C++ ↵Anders Carlsson
reference. llvm-svn: 106477
2010-06-17objective-C++ IRGen: property reference as an Fariborz Jahanian
lvalue when performing a derived-to-base conversion. Fixes radar 7501812. Added an executable test to llvm-test suite. llvm-svn: 106247
2010-06-17Objective-c++ IRGen. Support for @selector expression asFariborz Jahanian
an lvalue. Fixes PR7390. llvm-svn: 106235
2010-06-15Move CodeGenOptions.h *back* into Frontend. This should have been done when theChandler Carruth
dependency edge was reversed such that CodeGen depends on Frontend. llvm-svn: 106065
2010-05-22Re-land the fix for PR7139.Anders Carlsson
llvm-svn: 104446
2010-05-22Improve our handling of reference binding for subobjects ofDouglas Gregor
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
2010-05-21Unbreak self-host.Anders Carlsson
llvm-svn: 104390