[PATCH] D81624: [CodeGen] Simplify the way lifetime of block captures is extended

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 17:47:47 PDT 2020


ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a project: clang.
Herald added subscribers: ributzka, jfb, dexonsmith, jkorous.

Rather than pushing inactive cleanups for the block captures at the entry of a full expression and activating them during the creation of the block literal, just call `pushLifetimeExtendedDestroy` to ensure the cleanups are popped at the end of the scope enclosing the block expression.

I've made sure that the lifetime of block captures in a return statement doesn't get extended beyond the end of the return statement except when the `BlockDecl` isn't in the cleanup object list of the return statement's `ExprWithCleanups` (see `test22` I added to arc-blocks.m).

This addresses the feedback I got in the following review: https://reviews.llvm.org/D64464#inline-690623

rdar://problem/63996471


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81624

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBlocks.h
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGCleanup.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/test/CodeGenCXX/blocks-cxx11.cpp
  clang/test/CodeGenCXX/blocks.cpp
  clang/test/CodeGenObjC/arc-blocks.m
  clang/test/CodeGenObjC/arc-foreach.m
  clang/test/CodeGenObjC/noescape.m
  clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81624.270002.patch
Type: text/x-patch
Size: 43099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200611/cc3e0f36/attachment-0001.bin>


More information about the cfe-commits mailing list