[PATCH] D26410: [CodeGen] Don't emit the same global block multiple times.
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 8 12:10:10 PST 2016
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rjmccall.
george.burgess.iv added a subscriber: cfe-commits.
https://reviews.llvm.org/D14274 makes our constexpr evaluator more aggressive with some variables marked `const`. This changes how we behave on code like the following:
void foo() {
void (^const block_A)(void) = ^{ return; };
get_kernel_work_group_size(block_A);
get_kernel_work_group_size(block_A);
}
The constexpr evaluator will now give us `^{ return; }` three times (one for each use of `block_A`) instead of once (in `block_A`'s assignment). CodeGen emits a block every time it gets handed a `BlockExpr`, so we end up emitting the code for `^{ return; }` three times in total. We can fix this by tracking which global `BlockExpr`s we've already generated code for.
This seems to not happen for local `BlockExpr`s, since the constexpr fails for `BlockExpr`s with captures (see `PointerExprEvaluator::VisitBlockExpr` in lib/AST/ExprConstant.cpp). That said, I'm happy to add this uniquing code for `BlockExpr`s with captures if anyone wants me to.
https://reviews.llvm.org/D26410
Files:
lib/CodeGen/CGBlocks.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.h
test/CodeGenCXX/block-in-ctor-dtor.cpp
test/CodeGenOpenCL/cl20-device-side-enqueue.cl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26410.77225.patch
Type: text/x-patch
Size: 8318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161108/12dd086f/attachment.bin>
More information about the cfe-commits
mailing list