[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 21 20:53:19 PST 2019
rjmccall added a comment.
The correctness condition here is solely that we cannot allow the block literal to go out of scope before the variable that it is assigned to. (Local block literals with captures have lifetimes like C compound literals: until the end of the enclosing block, rather than the end of the full-expression.) So doing this blindly for assignments is problematic because you'd need to reason about relative lifetimes, but doing it for initialization should always be fine. I don't see any reason why address-taken-ness would matter as long as that condition holds.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58514/new/
https://reviews.llvm.org/D58514
More information about the cfe-commits
mailing list