Skip to content

[inliner] Treat inline_always as meaning truly inline_always even in … #20589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/SILOptimizer/Transforms/PerformanceInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ addToBBCounts(llvm::DenseMap<SILBasicBlock *, uint64_t> &BBToWeightMap,
}
}

static bool isInlineAlwaysCallSite(SILFunction *Callee) {
return Callee->getInlineStrategy() == AlwaysInline || Callee->isTransparent();
}

static void
calculateBBWeights(SILFunction *Caller, DominanceInfo *DT,
llvm::DenseMap<SILBasicBlock *, uint64_t> &BBToWeightMap) {
Expand Down Expand Up @@ -787,6 +791,23 @@ void SILPerformanceInliner::collectAppliesToInline(

auto *Callee = getEligibleFunction(AI, WhatToInline);
if (Callee) {
// Check if we have an always_inline or transparent function. If we do,
// just add it to our final Applies list and continue.
if (isInlineAlwaysCallSite(Callee)) {
NumCallerBlocks += Callee->size();
Applies.push_back(AI);
continue;
}

// Next make sure that we do not have more blocks than our overall
// caller block limit at this point. In such a case, we continue. This
// will ensure that any further non inline always functions are skipped,
// but we /do/ inline any inline_always functions remaining.
if (NumCallerBlocks > OverallCallerBlockLimit)
continue;

// Otherwise, calculate our block weights and determine if we want to
// inline this.
if (!BlockWeight.isValid())
BlockWeight = SPA->getWeight(block, Weight(0, 0));

Expand All @@ -798,8 +819,6 @@ void SILPerformanceInliner::collectAppliesToInline(
InitialCandidates.push_back(AI);
}
}
if (NumCallerBlocks > OverallCallerBlockLimit)
break;

domOrder.pushChildrenIf(block, [&] (SILBasicBlock *child) {
if (CBI.isSlowPath(block, child)) {
Expand Down