[PATCH] D89903: [CodeGen] Crash instead of generating broken code with self-capturing __block var

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 11:54:23 PDT 2020


rjmccall added a comment.

It's not optimal, but an alternative would be to force the variable to the heap immediately rather than waiting for a potential block copy.  The variable would actually be uninitialized during its "copy", so we'd need to give it a trivial copy helper.  But once the variable's been moved to the heap, it's never copied again, so that's fine.

We can force it to the heap using the public ABI for `__block` variables by copying and then immediately disposing of it.  (That would leave a reference from the stack, which is what we want.)  It would be better to have some way of generating it on the heap to begin it, but there's no ABI support for that right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89903



More information about the cfe-commits mailing list