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 BlockExprs we've already generated code for.
This seems to not happen for local BlockExprs, since the constexpr fails for BlockExprs with captures (see PointerExprEvaluator::VisitBlockExpr in lib/AST/ExprConstant.cpp). That said, I'm happy to add this uniquing code for BlockExprs with captures if anyone wants me to.
We conventionally name these things "set" rather than "put".