Commit Graph

359 Commits

Author SHA1 Message Date
John McCall 9916e3fa93 In the fragile ObjC ABI, save the caught exception to the side if there are
both @catches and a @finally, because the second call to @objc_exception_try_enter
will clobber the exception slot.  Fixes rdar://problem/8440970.

llvm-svn: 115575
2010-10-04 23:42:51 +00:00
Fariborz Jahanian de744dcce1 Restore test. Is for //rdar://8493239
llvm-svn: 115349
2010-10-01 21:26:26 +00:00
Fariborz Jahanian 220d971ace Remove test until further notice.
llvm-svn: 115258
2010-10-01 01:01:03 +00:00
Fariborz Jahanian ef1fb2d1d1 Fix test.
llvm-svn: 115253
2010-10-01 00:27:17 +00:00
Fariborz Jahanian 885e9dff93 Output debug info. for ivars declared in class
extension and implementation.
Fixes rdar://8493239.

llvm-svn: 115248
2010-10-01 00:01:53 +00:00
Devang Patel 7c086227e6 Attach aritifical attribute with implicit parameters.
Radar 8493141.

llvm-svn: 115104
2010-09-29 23:09:21 +00:00
Chris Lattner 775e635b5a update a bunch of tests that are using the x86 backend instead of grepping IR :(
llvm-svn: 114535
2010-09-22 06:09:31 +00:00
Fariborz Jahanian 0aa35b9cf5 Block description for trivial block literals have
their 'isa' field scanned regardless.

llvm-svn: 113749
2010-09-13 16:09:44 +00:00
Fariborz Jahanian 933c6723a4 Fixes an obscure bug in importd block variable layout
information when imported variable is used
more than once. Originally though to be a bug in importing
block varibles. Fixes radar 8417746.

llvm-svn: 113675
2010-09-11 01:27:29 +00:00
Fariborz Jahanian cfddabf5a3 Block ivar layout must assume that the 'isa'
field of the block descriptor is GC'able (scanned)
as this what the runtime expects (one can send it 
messages). Radar 8394947.

llvm-svn: 113454
2010-09-09 00:21:45 +00:00
Fariborz Jahanian 366a94822b Local static block variable referecned in its
block-literal initializer expression causes IRgen to crash.
This patch fixes by saving it in StaticLocalDecl map
already used for such purposes. (radar 8390455).

llvm-svn: 113307
2010-09-07 23:26:17 +00:00
Argyrios Kyrtzidis 2fdb5b5955 LastFieldBitfield in CGObjCCommonMac::BuildAggrIvarLayout keeps bitfields or unnamed fields but later the code
assumes that it's always a bitfield. This can lead to a crash (reported at rdar://8368320).

llvm-svn: 113154
2010-09-06 12:00:10 +00:00
Fariborz Jahanian 60babfb8a1 Casting of a property reference to 'void' did not
generate the necessary code. This patch fixes it.
// rdar://8389655

llvm-svn: 113079
2010-09-04 19:49:18 +00:00
Daniel Dunbar 09c8fbe812 tests: Fix a dependency on the temporary value names.
llvm-svn: 112917
2010-09-03 00:24:06 +00:00
Daniel Dunbar a70fab8dd7 IRgen/Obj-C: Rewrite Objective-C bit-field access to compute the access strategy
using the same methods as used for normal structures.
 - This fixes problems with reading past the end of the structure and with
   handling straddled bit-field access.

llvm-svn: 112914
2010-09-02 23:53:31 +00:00
Chris Lattner 369721a16e stop looking for #uses comments.
llvm-svn: 112898
2010-09-02 22:48:26 +00:00
Devang Patel 9cd85d1c77 Robustify test.
llvm-svn: 112062
2010-08-25 17:32:22 +00:00
Daniel Dunbar 5eb22ab7d8 tests: Disable this test for now, it is overly pessimistic and I am not sure how to fix it.
llvm-svn: 112023
2010-08-25 03:40:27 +00:00
Fariborz Jahanian bf9294fb65 Support for IRGen of synthesize bitfield ivars in
objc-nonfragile-abi2 (radar 7824380).

llvm-svn: 111823
2010-08-23 18:51:39 +00:00
Fariborz Jahanian 68e69ca9f9 Patch to issue warning when colllection expresion's type
does not implement 'countByEnumeratingWithState' API.
Implements radar 7634669.

llvm-svn: 110964
2010-08-12 22:25:42 +00:00
John McCall ffe4630f3d When re-raising an exception after a cleanup, we need to call _Unwind_Resume_or_Rethrow
instead of _Unwind_Resume.  With SJLJ exceptions, this is spelled
"_Unwind_SjLj_Resume_or_Rethrow", not "_Unwind_SjLj_Resume", which has
significantly different semantics.

We should actually never be generating a call to _Unwind_SjLj_Resume directly;
even if we were generating true cleanups (which we aren't because of the
horrible hack), we should be calling __cxa_end_cleanup() on ARM.  I
haven't implemented this because there's little point as long as the HH is
present.

I believe this fixes <rdar://problem/8281377>.

llvm-svn: 110851
2010-08-11 20:59:53 +00:00
Fariborz Jahanian d539d098a4 IRGen support for functions returning objc object
types. Fixes PR7865.

llvm-svn: 110832
2010-08-11 17:37:35 +00:00
John McCall ca7993f572 Make this test a little less dependent on exact optimizer results.
llvm-svn: 110770
2010-08-11 02:06:44 +00:00
John McCall cebe0ca75e Fix a bug in @finally emission in both the fragile and non-fragile EH schemes
where we weren't accounting for the possibility that a @finally block might
have internal cleanups and therefore might write to the cleanup destination slot.

Fixes <rdar://problem/8293901>.

llvm-svn: 110760
2010-08-11 00:16:14 +00:00
Fariborz Jahanian f95e358004 Finishing up block variable layout API by supporting
union type variables and their nesting inside other
aggregate types.

llvm-svn: 110448
2010-08-06 16:28:55 +00:00
Fariborz Jahanian 903aba39ee Add support for block imported struct variable layout info.
(objc gc and blocks in NeXt runtime).

llvm-svn: 110377
2010-08-05 21:00:25 +00:00
Fariborz Jahanian 9659f6b540 Block variable layout bitmap API generation.
llvm-svn: 110287
2010-08-04 23:55:24 +00:00
John McCall 2dd7d44135 Some more correctness fixes and code-size optimizations for fragile-ABI
ObjC exceptions:
  - don't enter a try for the catch blocks unless there's a finally
  - put the setjmp buffer in the locals set for liveness reasons
  - dump the sync object into an alloca in the locals set for liveness reasons
Some of this can go away if the backend starts to properly calculate liveness
in the presence of setjmp (which would also be a *much* stabler solution).

llvm-svn: 110188
2010-08-04 05:59:32 +00:00
John McCall 42227edc79 Fix fragile-ABI ObjC exceptions in the presence of optimization with
the magic of inline assembly.  Essentially we use read and write hazards
on the set of local variables to force flushing locals to memory
immediately before any protected calls and to inhibit optimizing locals
across the setjmp->catch edge.  Fixes rdar://problem/8160285

llvm-svn: 109960
2010-07-31 23:20:56 +00:00
Daniel Dunbar cda4307308 Revert "Re-apply fixed version of 108749, correctly conditionalizing the new
sections on", this change uncovered a possible linker bug which resulted in the
wrong messages getting dispatched. Backing this out while we investigate...

llvm-svn: 109817
2010-07-29 22:57:21 +00:00
Chris Lattner 3a44c7e55d now that we have CGT around, we can start using preferred types
for return values too.  Instead of compiling something like:

struct foo {
  int *X;
  float *Y;
};

struct foo test(struct foo *P) { return *P; }

to:

%1 = type { i64, i64 }

define %1 @test(%struct.foo* %P) nounwind {
entry:
  %retval = alloca %struct.foo, align 8           ; <%struct.foo*> [#uses=2]
  %P.addr = alloca %struct.foo*, align 8          ; <%struct.foo**> [#uses=2]
  store %struct.foo* %P, %struct.foo** %P.addr
  %tmp = load %struct.foo** %P.addr               ; <%struct.foo*> [#uses=1]
  %tmp1 = bitcast %struct.foo* %retval to i8*     ; <i8*> [#uses=1]
  %tmp2 = bitcast %struct.foo* %tmp to i8*        ; <i8*> [#uses=1]
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 16, i32 8, i1 false)
  %0 = bitcast %struct.foo* %retval to %1*        ; <%1*> [#uses=1]
  %1 = load %1* %0, align 1                       ; <%1> [#uses=1]
  ret %1 %1
}

We now get the result more type safe, with:

define %struct.foo @test(%struct.foo* %P) nounwind {
entry:
  %retval = alloca %struct.foo, align 8           ; <%struct.foo*> [#uses=2]
  %P.addr = alloca %struct.foo*, align 8          ; <%struct.foo**> [#uses=2]
  store %struct.foo* %P, %struct.foo** %P.addr
  %tmp = load %struct.foo** %P.addr               ; <%struct.foo*> [#uses=1]
  %tmp1 = bitcast %struct.foo* %retval to i8*     ; <i8*> [#uses=1]
  %tmp2 = bitcast %struct.foo* %tmp to i8*        ; <i8*> [#uses=1]
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 16, i32 8, i1 false)
  %0 = load %struct.foo* %retval                  ; <%struct.foo> [#uses=1]
  ret %struct.foo %0
}

That memcpy is completely terrible, but I don't know how to fix it.

llvm-svn: 109729
2010-07-29 04:46:19 +00:00
Fariborz Jahanian 72cdffa401 Return type of a setter call caused by
use of property-dot syntax using 'super' as receiver
is 'void'. This fixes a bug in generating correct
API for setter call. Fixes radar 8203426.

llvm-svn: 109297
2010-07-24 00:34:08 +00:00
John McCall ad5d61e227 Revise cleanup IR generation to fix a major bug with cleanups (PR7686)
as well as some significant asymptotic inefficiencies with threading
multiple jumps through deep cleanups.

llvm-svn: 109274
2010-07-23 21:56:41 +00:00
Jim Grosbach 71d963e954 Re-apply fixed version of 108749, correctly conditionalizing the new sections on
ObjC ABI version 2 this time.

llvm-svn: 108847
2010-07-20 16:20:26 +00:00
Jim Grosbach 428a7103d9 and revert the related tests, too
llvm-svn: 108766
2010-07-19 22:53:57 +00:00
Jim Grosbach 6331d9781c Update tests for r108749
llvm-svn: 108754
2010-07-19 21:39:14 +00:00
Daniel Dunbar 2c91be4261 IRgen: Add a test case I forgot to commit at some point.
llvm-svn: 108713
2010-07-19 17:11:38 +00:00
John McCall 36ea3723c0 The GNU-runtime ObjC personality function doesn't let us rethrow with URR for
multiple reasons.  Rethrow with _objc_exception_throw instead.  Fixes PR7656.

llvm-svn: 108595
2010-07-17 00:43:08 +00:00
John McCall 2b7fc3828e Teach IR generation how to lazily emit cleanups. This has a lot of advantages,
mostly in avoiding unnecessary work at compile time but also in producing more
sensible block orderings.

Move the destructor cleanups for local variables over to use lazy cleanups.
Eventually all cleanups will do this;  for now we have some awkward code
duplication.

Tell IR generation just to never produce landing pads in -fno-exceptions.
This is a much more comprehensive solution to a problem which previously was
half-solved by checks in most cleanup-generation spots.

llvm-svn: 108270
2010-07-13 20:32:21 +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
Daniel Dunbar 8c94ffe776 IRgen: Assignment to Objective-C properties shouldn't reload the value, for
complex values either. Previously we did this properly for regular assignment,
but not for compound assignment.
 - Also, tidy up assignment code a bit to look more like the scalar path.

llvm-svn: 107217
2010-06-29 22:44:21 +00:00
Daniel Dunbar c85ea8e175 IRgen: Assignment to Objective-C properties shouldn't reload the value (which
would trigger an extra method call).
 - While in the area, I also changed Clang to not emit an unnecessary load from
   'x' in cases like 'y = (x = 1)'.

llvm-svn: 107210
2010-06-29 22:00:45 +00:00
Fariborz Jahanian a9f90275cc Trying to make BuildBot happy again (related to PR7431).
llvm-svn: 106553
2010-06-22 17:08:32 +00:00
Fariborz Jahanian 7966aff294 Fixes a problem in generation of meta-data for
category implementation whereby property list was missing.
NeXt ObjC runtime (radar 8093297).

llvm-svn: 106550
2010-06-22 16:33:55 +00:00
Douglas Gregor de049cdbe6 Attempt to fix test
llvm-svn: 106522
2010-06-22 02:17:07 +00:00
Fariborz Jahanian 2990e3a502 Test case for PR7431 by Nico Weber.
llvm-svn: 106494
2010-06-21 22:21:57 +00:00
Rafael Espindola b35e7b8659 Fix tests that I missed from my previous commit.
llvm-svn: 106118
2010-06-16 17:49:52 +00:00
Fariborz Jahanian be21aa34a0 When using property-dot assignment syntax to call a setter method,
type of rhs need be compared to setter's argument and
not the getter type. Fixes radar 8062778

llvm-svn: 105560
2010-06-07 22:02:01 +00:00
Fariborz Jahanian a2d7c34e93 Fixed a block regression caused by trying to use
an existing ir for load of a bock variable. This cannot be
done across basic blocks.
Fixes radar 8064140.

llvm-svn: 105549
2010-06-07 19:39:39 +00:00
David Chisnall b190a2c74a Fixed Objective-C type encoding for bitfields for the GNU runtime to match the encoding used by GCC.
llvm-svn: 105451
2010-06-04 01:10:52 +00:00