[PATCH] D45384: [ObjC++] Never pass structs with `__weak` fields in registers

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 6 12:59:11 PDT 2018


ahatanak added a comment.

In https://reviews.llvm.org/D45384#1060164, @rjmccall wrote:

> Well, but I think CanPassInRegisters==false in the base class does always mean CanPassInRegisters==false in the subclass.


I think there are cases that is not true. If I compile the following code, S0 (base class) is passed indirectly and S1 (derived class) is passed directly.

  struct S0 {
    S0();
    S0(const S0 &) = default;
    S0(S0 &&);
    ~S0() = default;
    int *p;
  };
  
  struct S1 : S0 {
    S1();
    S1(const S1 &) = default;
    S1(S1 &&) = delete;
    ~S1() = default;
    int a;
  };
  
  void foo1(S0);
  void foo1(S1);
  
  void test0(S0 *a) {
    foo1(*a);
  }
  
  void test1(S1 *a) {
    foo1(*a);
  }

By the way, I meant to say "CanPassInRegisters=true in the *base class*" not "CanPassInRegisters=true in the subclass".


Repository:
  rC Clang

https://reviews.llvm.org/D45384





More information about the cfe-commits mailing list