ahatanak added a comment.

Sorry for the delay in responding.

Instead of reverting the commit, can we put this optimization behind an 
off-by-default flag? As far as we can tell, the only problem we have now that 
is preventing us to enable this optimization is that clang doesn't copy a block 
to the heap when the block is converted to a non-block type (e.g., `const void 
*`) in some cases.

For example, the block isn't copied to the heap in the following example. Note 
that this happens without the optimization this patch is reverting.

  void foo1(const void *) __attribute__((cf_audited_transfer ));
  
  void foo2(id a) {
    // clang should copy the block to the heap, since foo1 doesn't know it's 
receiving a block, but it doesn't.
    foo1((const void *)^{ (void)a; });
  }

This doesn't look too hard to fix. We probably just have to insert 
`ARCExtendBlockObject` into the AST.

Once we fix that problem, we can turn on the flag in both open source and 
Apple's compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108243

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to