[PATCH] D108243: Revert "Avoid needlessly copying a block to the heap when a block literal"

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 27 12:46:37 PDT 2021


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



More information about the cfe-commits mailing list