Add the `objc_class_stub` attribute.

Authored by rjmccall on May 29 2019, 9:09 PM.


Add the objc_class_stub attribute.

Swift requires certain classes to be not just initialized lazily on first
use, but actually allocated lazily using information that is only available
at runtime. This is incompatible with ObjC class initialization, or at least
not efficiently compatible, because there is no meaningful class symbol
that can be put in a class-ref variable at load time. This leaves ObjC
code unable to access such classes, which is undesirable.

objc_class_stub says that class references should be resolved by calling
a new ObjC runtime function with a pointer to a new "class stub" structure.
Non-ObjC compilers (like Swift) can simply emit this structure when ObjC
interop is required for a class that cannot be statically allocated,
then apply this attribute to the @interface in the generated ObjC header
for the class.

This attribute can be thought of as a generalization of the existing
objc_runtime_visible attribute which permits more efficient class
resolution as well as supporting the additon of categories to the class.
Subclassing these classes from ObjC is currently not allowed.

Patch by Slava Pestov!

llvm-svn: 362054


rjmccallMay 29 2019, 9:09 PM
rG1f67d9427931: [X86] Add ENQCMD instructions