mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user