[PATCH] D76570: [AArch64] Homogeneous Prolog and Epilog for Size Optimization

陈俊 via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 19:26:49 PST 2020


JuunChen added a comment.

Hi, I may have found a problem.

It says in the official document <https://clang.llvm.org/docs/AttributeReference.html#objc-direct-members> ---- the `setter` and `getter` of properties will become `direct` if `objc_direct_members` is placed on the @implementation block:

> When objc_direct_members is placed on an @implementation block, methods defined in the block are considered to be declared as direct unless they have been previously declared as non-direct in any interface of the class. **This includes the implicit method definitions introduced by synthesized properties, including auto-synthesized properties.**

But I found that this way didn't make property's `setter` or `getter` became `direct` method. 
I wrote 3 demos, the code is as follows:

  //normal_excutable
  @interface ViewController ()
  @property (nonatomic, copy) NSString *name;
  @end
  
  @implementation ViewController
  @end



  //use_objc_direct_members
  @interface ViewController ()
  @property (nonatomic, copy) NSString *name;
  @end
  
  __attribute__((objc_direct_members))
  @implementation ViewController
  @end



  //use_direct_property
  @interface ViewController ()
  @property (nonatomic, copy, direct) NSString *name;
  @end
  
  @implementation ViewController
  @end

Compile them separately and compare their Mach-O products:
F14468301: image.png <https://reviews.llvm.org/F14468301>

>From the picture:

- In normal executable, the `name` and `setName:` are in the `ViewController`'s method list, there are not direct methods.
- When placed `__attribute__((objc_direct_members))` above @implementation, nothing is happened, the `name` and `setName:` are also not direct methods. This does not seem to be consistent with what is described in the documentation.
- When used `direct` in property, it's works well, the `name` and `setName:` are not in the method list, they become the direct methods.

So, I don't know if I misunderstood the sentence:

> "This includes the implicit method definitions introduced by synthesized properties, including auto-synthesized properties."

Or the document writes error ? Or the `objc_direct_members` has a bug?

I would be very, very grateful if you could answer my questions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76570/new/

https://reviews.llvm.org/D76570



More information about the llvm-commits mailing list