Commit Graph

215 Commits

Author SHA1 Message Date
John McCall f3735e01ce Restore the lvalue-to-rvalue conversion patch with a minimal fix.
llvm-svn: 120555
2010-12-01 04:43:34 +00:00
John McCall 4f22c9de48 L-value to r-value conversion is not ready for prime-time.
llvm-svn: 120433
2010-11-30 17:58:55 +00:00
John McCall 824fd1dcff Introduce an r-value to l-value cast kind. I'm not promising anything
about the reliability of this yet.

llvm-svn: 120422
2010-11-30 10:13:06 +00:00
John McCall 5b26f65b3d Reset the lifetime-managed flag between emission of the agg conditional
branches.  Fixes PR8623.

llvm-svn: 119408
2010-11-17 00:07:33 +00:00
John McCall d50a27111c Kill CK_Unknown and flesh out the documentation for the existing CastKinds.
llvm-svn: 119331
2010-11-16 05:46:29 +00:00
Fariborz Jahanian c123623d28 After discussion with Doug and John, I am reverting
the patch. 

llvm-svn: 117159
2010-10-22 22:05:03 +00:00
Fariborz Jahanian 0196aa28ec Patch fixes miscompile with non-trivial copy constructors and
statement expressions, //rdar: //8540501

llvm-svn: 117146
2010-10-22 21:01:02 +00:00
Douglas Gregor 7a2b425ee1 Revert the hack Chris Lattner added in r97981 to work around
brokenness in the designated-initializer ASTs. The ASTs were fixed by
Alp Toker's patch (r116098) for PR6955. Fixes PR6537.

llvm-svn: 116101
2010-10-08 20:56:19 +00:00
John McCall 58649dc609 Initialize AggValueSlot's flags along all paths, plus minor beautification.
Prospective fix for broken commit in r114045.

llvm-svn: 114060
2010-09-16 03:13:23 +00:00
Fariborz Jahanian b60e70f963 Patch to move RequiresGCollection bit to
AggValueSlot slot.

llvm-svn: 114045
2010-09-16 00:20:07 +00:00
John McCall 7a626f63f7 one piece of code is responsible for the lifetime of every aggregate
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-15 10:14:12 +00:00
Chris Lattner 52bcf96384 move the hackaround for PR6537 to catch unions as well,
fixing the ICE in PR7151

llvm-svn: 113130
2010-09-06 00:13:11 +00:00
Chris Lattner f53c096813 clean up some formatting.
llvm-svn: 113129
2010-09-06 00:11:41 +00:00
John McCall e302792b61 GCC didn't care for my attempt at API compatibility, so brute-force everything
to the new constants.

llvm-svn: 112047
2010-08-25 11:45:40 +00:00
John McCall 8d75243029 Expression statements undergo lvalue-to-rvalue conversion in C,
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-25 02:50:31 +00:00
Douglas Gregor 630c76efb0 When performing value-initialization for a class with a non-trivial,
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-22 16:15:35 +00:00
John McCall a1dee5300b Experiment with using first-class aggregates to represent member function
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-22 10:59:02 +00:00
John McCall 1c456c89dc Abstract out member-pointer creation. I'm really unhappy about the current
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-22 06:43:33 +00:00
John McCall 84fa510aa9 Abstract more member-pointerness out.
llvm-svn: 111771
2010-08-22 04:16:24 +00:00
John McCall a8bbb82c55 Abstract out member-pointer conversions.
Pretty much everything having to do with member pointers is ABI-specific.

llvm-svn: 111770
2010-08-22 03:04:22 +00:00
Daniel Dunbar e50dda95ee IRgen/LValue: Add LValue::setNonGC instead of SetObjCNonGC, for consistency with isNonGC().
llvm-svn: 111718
2010-08-21 03:22:38 +00:00
Daniel Dunbar 2e442a00b3 IRgen: Switch more MakeAddr() users to MakeAddrLValue; this time for calls 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-21 03:15:20 +00:00
Daniel Dunbar f6fb7e2b53 IRgen: Switch a bunch of trivial MakeAddr calls to use MakeAddrLValue.
llvm-svn: 111716
2010-08-21 03:08:16 +00:00
John McCall cf14216509 Store inheritance paths after CastExprs instead of inside them.
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-08-07 06:22:56 +00:00
Douglas Gregor 51954276cc Introduce a new cast kind for an "lvalue bitcast", which handles
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-13 23:17:26 +00:00
Douglas Gregor 747eb7840a Reinstate the fix for PR7556. A silly use of isTrivial() was
suppressing copies of objects with trivial copy constructors.

llvm-svn: 107857
2010-07-08 06:14:04 +00:00
Chris Lattner cb7696cf35 fix the clang side of PR7437: EmitAggregateCopy
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-08 00:07:45 +00:00
Douglas Gregor e182370eda Revert r107828 and r107827, the fix for PR7556, which seems to be
breaking bootstrap on Linux.

llvm-svn: 107837
2010-07-07 23:37:33 +00:00
Douglas Gregor 6df2b8c3ac Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect its
newly-narrowed scope. No functionality change.

llvm-svn: 107828
2010-07-07 22:43:56 +00:00
John McCall bd30929e4d Validated by nightly-test runs on x86 and x86-64 darwin, including after
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-06 01:34:17 +00:00
Chris Lattner 818efb64a3 misc tidying
llvm-svn: 106978
2010-06-27 07:40:06 +00:00
Chris Lattner 5e016ae983 finally get around to doing a significant cleanup to irgen:
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-27 07:15:29 +00:00
Anders Carlsson 04775f8413 Change EmitReferenceBindingToExpr to take a decl instead of a boolean.
llvm-svn: 106949
2010-06-26 16:35:32 +00:00
Fariborz Jahanian 021510e96f Patch adds support for copying of those
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
2010-06-15 22:44:06 +00:00
Eli Friedman c8731be34d Fix for PR7040: Don't try to compute the LLVM type for a function where it
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
2010-05-30 06:03:20 +00:00
John McCall cc04e9f6b9 Re-teach IR gen to perform GC moves on rvalues resulting from various ObjC
expressions.  Essentially, GC breaks a certain form of the return-value
optimization.

llvm-svn: 104454
2010-05-22 22:13:32 +00:00
Anders Carlsson c0964b60e5 Re-land the fix for PR7139.
llvm-svn: 104446
2010-05-22 17:35:42 +00:00
Douglas Gregor aae38d6610 Improve our handling of reference binding for subobjects of
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-22 05:17:18 +00:00
John McCall 78a151138a Push a return-value slot throughout ObjC message-send codegen. Will be
critical for ObjC++ correctness;  hard to test independently of various
required Sema changes, though.

llvm-svn: 104422
2010-05-22 01:48:05 +00:00
Anders Carlsson c866eb5ba9 Unbreak self-host.
llvm-svn: 104390
2010-05-21 22:17:48 +00:00
Anders Carlsson da1641cd12 Rename CodeGenFunction::EmitMemSetToZero to EmitNullInitialization. Handle setting null data member pointers correctly. Fixes PR7139.
llvm-svn: 104387
2010-05-21 21:45:41 +00:00
Fariborz Jahanian 6855ba2c95 Copy construction of non-trivial properties must not
be turned into a setter call (fixes radar 8008649).

llvm-svn: 104235
2010-05-20 16:46:55 +00:00
Douglas Gregor 265b8b8de0 Picky, picky
llvm-svn: 104230
2010-05-20 15:48:29 +00:00
Douglas Gregor c19108118d Fix a thinko
llvm-svn: 104229
2010-05-20 15:47:46 +00:00
Douglas Gregor f22101a059 Assert that we do not try to memcpy a non-POD class type in C++. This
particular issue was the cause of the Boost.Interprocess failures, and
in general will lead to horrendous, hard-to-diagnose miscompiles. The
assertion itself has survives self-host and a full Boost build, so we
are close to eradicating this problem in C++.

Note that the assertion is *not* turned on for Objective-C++, where we
still have problems with introducing memcpy's of non-POD class
types. That part of the assertion will go away as soon as we fix the
known issues in Objective-C++.

llvm-svn: 104227
2010-05-20 15:39:01 +00:00
Douglas Gregor 1c073f47da Emit an lvalue dynamic_cast even if the result is not used. Another
part (or possibly all) of PR7132.

llvm-svn: 103810
2010-05-14 21:31:02 +00:00
Anders Carlsson a1bc38d53e Remove an unused function.
llvm-svn: 103793
2010-05-14 19:48:27 +00:00
Douglas Gregor aee1f51485 If we're generating code to create a pointer-to-member function
aggregate and the result of the aggregate is unused, bail out
early. Fixes PR7027.

llvm-svn: 102942
2010-05-03 20:00:27 +00:00
Anders Carlsson 3572d44190 When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
llvm-svn: 102921
2010-05-03 16:05:06 +00:00
Anders Carlsson 16e94af67c Don't copy or initialize empty classes. Fixes PR7012.
llvm-svn: 102891
2010-05-03 01:20:20 +00:00