Commit Graph

9 Commits

Author SHA1 Message Date
Akira Hatanaka 48566aaab4 [CodeGen][ObjC] Convert '[self alloc]' in a class method to a call to
'objc_alloc(self)'

Also convert '[[self alloc] init]' in a class method to a call to
'objc_alloc_init(self)'.

rdar://problem/50855121

Differential Revision: https://reviews.llvm.org/D62643

llvm-svn: 362521
2019-06-04 16:29:58 +00:00
Erik Pilkington f6c645f9fd [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary
Any of these methods can be overridden, so we need to invoke these functions.

Differential revision: https://reviews.llvm.org/D61957

llvm-svn: 360802
2019-05-15 20:15:01 +00:00
Akira Hatanaka 34d28cf25f [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when
necessary.

Prior to r349952, clang used to call objc_msgSend when sending a release
messages, emitting an invoke instruction instead of a call instruction
when it was necessary to catch an exception. That changed in r349952
because runtime function objc_release is called as a nounwind function,
which broke programs that were overriding the dealloc method and
throwing an exception from it. This patch restores the behavior prior to
r349952.

rdar://problem/50253394

Differential Revision: https://reviews.llvm.org/D61803

llvm-svn: 360474
2019-05-10 21:54:16 +00:00
Erik Pilkington 1f7eda5aac [CodeGenObjC] Handle exceptions when calling objc_alloc or objc_allocWithZone
objc_alloc and objc_allocWithZone may throw exceptions if the
underlying method does. If we're in a @try block, then make sure we
emit an invoke instead of a call.

rdar://47610407

Differential revision: https://reviews.llvm.org/D57476

llvm-svn: 352687
2019-01-30 23:17:38 +00:00
Pete Cooper de0a8d37a0 Only convert objc messages to alloc to objc_alloc if the receiver is a class.
r348687 converted [Foo alloc] to objc_alloc(Foo).  However the objc runtime method only takes a Class, not an arbitrary pointer.

This makes sure we are messaging a class before we convert these messages.

rdar://problem/46943703

llvm-svn: 350224
2019-01-02 17:25:30 +00:00
Pete Cooper e5b64ea2b8 Convert some ObjC retain/release msgSends to runtime calls.
It is faster to directly call the ObjC runtime for methods such as retain/release instead of sending a message to those functions.

Differential Revision: https://reviews.llvm.org/D55869

Reviewed By: rjmccall

llvm-svn: 349952
2018-12-21 21:00:32 +00:00
Pete Cooper e388680dfa Convert some ObjC msgSends to runtime calls.
It is faster to directly call the ObjC runtime for methods such as alloc/allocWithZone instead of sending a message to those functions.

This patch adds support for converting messages to alloc/allocWithZone to their equivalent runtime calls.

Tests included for the positive case of applying this transformation, negative tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and also a driver test to ensure we enable this only for supported runtime versions.

Reviewed By: rjmccall

https://reviews.llvm.org/D55349

llvm-svn: 348687
2018-12-08 05:13:50 +00:00
Pete Cooper 948677131f Revert "Convert some ObjC msgSends to runtime calls."
This reverts commit r263607.

This change caused more objc_retain/objc_release calls in the IR but those
are then incorrectly optimized by the ARC optimizer.  Work is going to have
to be done to ensure the ARC optimizer doesn't optimize user written RR, but
that should land before this change.

This change will also need to be updated to take account for any changes required
to ensure that user written calls to RR are distinct from those inserted by ARC.

llvm-svn: 263984
2016-03-21 20:50:03 +00:00
Pete Cooper be6c750a8e Convert some ObjC msgSends to runtime calls.
It is faster to directly call the ObjC runtime for methods such as retain/release instead of sending a message to those functions.

This patch adds support for converting messages to retain/release/alloc/autorelease to their equivalent runtime calls.

Tests included for the positive case of applying this transformation, negative tests that we ensure we only convert "alloc" to objc_alloc, not "alloc2", and also a driver test to ensure we enable this only for supported runtime versions.

Reviewed by John McCall.

Differential Revision: http://reviews.llvm.org/D14737

llvm-svn: 263607
2016-03-16 00:33:21 +00:00