Don't apply the -Osize heuristic when inlining coroutines.

This is a performance hack: inlining a coroutine can promote heap
allocations of the frame to stack allocations, which is valuable
out of proportion to the normal weight.  There are surely more
principled ways of getting this effect, though.
This commit is contained in:
John McCall
2018-11-08 12:19:24 -05:00
parent 87e9fb5560
commit d339eab30c

View File

@@ -261,8 +261,12 @@ bool SILPerformanceInliner::isProfitableToInline(
int BaseBenefit = RemovedCallBenefit;
// Osize heuristic.
//
// As a hack, don't apply this at all to coroutine inlining; avoiding
// coroutine allocation overheads is extremely valuable. There might be
// more principled ways of getting this effect.
bool isClassMethodAtOsize = false;
if (OptMode == OptimizationMode::ForSize) {
if (OptMode == OptimizationMode::ForSize && !isa<BeginApplyInst>(AI)) {
// Don't inline into thunks.
if (AI.getFunction()->isThunk())
return false;