Skip to content

[PerformanceInliner] Reduce the code size impact of the exclusivity heuristic #21897

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
merged 1 commit into from
Jan 16, 2019
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
13 changes: 11 additions & 2 deletions lib/SILOptimizer/Transforms/PerformanceInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ llvm::cl::opt<bool> EnableSILInliningOfGenerics(
"sil-inline-generics", llvm::cl::init(false),
llvm::cl::desc("Enable inlining of generics"));

llvm::cl::opt<bool>
EnableSILAgressiveInlining("sil-agressive-inline", llvm::cl::init(false),
llvm::cl::desc("Enable agressive inlining"));

//===----------------------------------------------------------------------===//
// Performance Inliner
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -105,7 +109,7 @@ class SILPerformanceInliner {
/// The benefit of inlining an exclusivity-containing callee.
/// The exclusivity needs to be: dynamic,
/// has no nested conflict and addresses known storage
ExclusivityBenefit = RemovedCallBenefit + 125,
ExclusivityBenefit = RemovedCallBenefit + 10,

/// The benefit of inlining class methods with -Osize.
/// We only inline very small class methods with -Osize.
Expand Down Expand Up @@ -321,6 +325,10 @@ bool SILPerformanceInliner::isProfitableToInline(
// the exclusivity heuristic or not. We can *only* do that
// if AllAccessesBeneficialToInline is true
int ExclusivityBenefitWeight = 0;
int ExclusivityBenefitBase = ExclusivityBenefit;
if (EnableSILAgressiveInlining) {
ExclusivityBenefitBase += 500;
}

SubstitutionMap CalleeSubstMap = AI.getSubstitutionMap();

Expand Down Expand Up @@ -422,7 +430,8 @@ bool SILPerformanceInliner::isProfitableToInline(
if (BAI->hasNoNestedConflict() &&
(storage.isUniquelyIdentified() ||
storage.getKind() == AccessedStorage::Class)) {
BlockW.updateBenefit(ExclusivityBenefitWeight, ExclusivityBenefit);
BlockW.updateBenefit(ExclusivityBenefitWeight,
ExclusivityBenefitBase);
} else {
AllAccessesBeneficialToInline = false;
}
Expand Down