This provides a code size win on the caller side, since the init message send is done in the runtime function.
rdar://44987038
Thanks!
Erik
Paths
| Differential D57936
[CodeGenObjC] When available, emit a direct call to objc_alloc_init(cls) instead of [objc_alloc(cls) init] ClosedPublic Authored by erik.pilkington on Feb 7 2019, 6:38 PM.
Details Summary This provides a code size win on the caller side, since the init message send is done in the runtime function. rdar://44987038 Thanks!
Diff Detail Event Timeline
gparker42 added inline comments.
erik.pilkington added inline comments.
This revision is now accepted and ready to land.Feb 13 2019, 7:19 PM Closed by commit rC354056: [CodeGenObjC] Emit [[X alloc] init] as objc_alloc_init(X) when available (authored by epilk). · Explain WhyFeb 14 2019, 12:04 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 186784 clang/include/clang/Basic/ObjCRuntime.h
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenObjC/objc-alloc-init.m
|
You might need to check for a super message send, which can be a class message send in a class method.
Also, I think getInterface() can return null here, although it might need to be contrived to fit the other requirements. Class<SomeProtocol>, where that protocol declares +alloc? If there isn't a way to just emit the receiver pointer of a normal message send from an ObjCMessageExpr, that's really too bad.