Page MenuHomePhabricator

[CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when necessary.
ClosedPublic

Authored by ahatanak on May 10 2019, 1:29 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

ahatanak created this revision.May 10 2019, 1:29 PM
erik.pilkington added inline comments.
lib/CodeGen/CGObjC.cpp
2634–2646 ↗(On Diff #199071)

Can't you just write EmitCallOrInvoke(fn, value)? See what we do in emitObjCValueOperation, which can handle this case.

ahatanak updated this revision to Diff 199081.May 10 2019, 2:09 PM
ahatanak marked an inline comment as done.

Just call EmitCallOrInvoke.

erik.pilkington accepted this revision.May 10 2019, 2:10 PM

LGTM, thanks!

This revision is now accepted and ready to land.May 10 2019, 2:10 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2019, 2:51 PM