[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 27 16:24:31 PST 2018
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
This patch adds a command line option (-fdisable-tail-calls-esca
ping-blocks) that annotates escaping block invoke functions with attribute "disable-tail-calls". This is an option that helps users in debugging their code who spend a lot of time trying to figure out where a block came from.
The user who is asking for this command line option does not want to disable tail-call optimization for non-escaping blocks. For example, in the following code, we should not disable tail-call optimization for the block that is directly passed to function "noescapefunc":
void foo3(void);
void foo1() {
noescapefunc(^{ foo3(); }); // do not disable tail-call.
BlockTy b = ^{ foo3(); }; // disable tail-call.
noescapefunc(b);
}
Ideally, I think we want to avoid disabling tail-call optimization for block "b" too, as it doesn't escape. However, this patch doesn't do anything to avoid disabling tail-call optimization for the block, since that would require a more complex analysis.
rdar://problem/35758207
https://reviews.llvm.org/D43841
Files:
include/clang/AST/DeclObjC.h
include/clang/AST/Type.h
include/clang/Driver/Options.td
include/clang/Frontend/CodeGenOptions.def
lib/AST/DeclObjC.cpp
lib/AST/Type.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.h
lib/Driver/ToolChains/Clang.cpp
lib/Frontend/CompilerInvocation.cpp
test/CodeGenObjC/disable-tail-call-escaping-block.m
test/Driver/fdisable-tail-calls-escaping-blocks.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43841.136179.patch
Type: text/x-patch
Size: 10962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180228/69f4b3d3/attachment-0001.bin>
More information about the cfe-commits
mailing list