]> granicus.if.org Git - clang/commit
[CodeGen][ObjC] Make copying and disposing of a non-escaping block
authorAkira Hatanaka <ahatanaka@apple.com>
Fri, 20 Jul 2018 17:10:32 +0000 (17:10 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Fri, 20 Jul 2018 17:10:32 +0000 (17:10 +0000)
commit4e2bc94eda9c2a7ea117f8b1131899f28d2d446c
treec089cda16cbe150305d2b0096187663080598b96
parentdca1b442e96b8d768c34bae0c4dda84a1f06ce09
[CodeGen][ObjC] Make copying and disposing of a non-escaping block
no-ops.

A non-escaping block on the stack will never be called after its
lifetime ends, so it doesn't have to be copied to the heap. To prevent
a non-escaping block from being copied to the heap, this patch sets
field 'isa' of the block object to NSConcreteGlobalBlock and sets the
BLOCK_IS_GLOBAL bit of field 'flags', which causes the runtime to treat
the block as if it were a global block (calling _Block_copy on the block
just returns the original block and calling _Block_release is a no-op).

Also, a new flag bit 'BLOCK_IS_NOESCAPE' is added, which allows the
runtime or tools to distinguish between true global blocks and
non-escaping blocks.

rdar://problem/39352313

Differential Revision: https://reviews.llvm.org/D49303

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337580 91177308-0d34-0410-b5e6-96231b3b80d8
docs/Block-ABI-Apple.rst
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CGBlocks.h
test/CodeGenObjC/noescape.m