Skip to content

Commit edd7a22

Browse files
authored
Merge pull request #21921 from shajrawi/inline_cherry_excl
[PerformanceInliner] Reduce the code size impact of the exclusivity heuristic
2 parents 08e20c0 + 5a9c3fc commit edd7a22

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ llvm::cl::opt<bool> EnableSILInliningOfGenerics(
3737
"sil-inline-generics", llvm::cl::init(false),
3838
llvm::cl::desc("Enable inlining of generics"));
3939

40+
llvm::cl::opt<bool>
41+
EnableSILAgressiveInlining("sil-agressive-inline", llvm::cl::init(false),
42+
llvm::cl::desc("Enable agressive inlining"));
43+
4044
//===----------------------------------------------------------------------===//
4145
// Performance Inliner
4246
//===----------------------------------------------------------------------===//
@@ -104,7 +108,7 @@ class SILPerformanceInliner {
104108
/// The benefit of inlining an exclusivity-containing callee.
105109
/// The exclusivity needs to be: dynamic,
106110
/// has no nested conflict and addresses known storage
107-
ExclusivityBenefit = RemovedCallBenefit + 125,
111+
ExclusivityBenefit = RemovedCallBenefit + 10,
108112

109113
/// The benefit of inlining class methods with -Osize.
110114
/// We only inline very small class methods with -Osize.
@@ -320,6 +324,10 @@ bool SILPerformanceInliner::isProfitableToInline(
320324
// the exclusivity heuristic or not. We can *only* do that
321325
// if AllAccessesBeneficialToInline is true
322326
int ExclusivityBenefitWeight = 0;
327+
int ExclusivityBenefitBase = ExclusivityBenefit;
328+
if (EnableSILAgressiveInlining) {
329+
ExclusivityBenefitBase += 500;
330+
}
323331

324332
SubstitutionMap CalleeSubstMap = AI.getSubstitutionMap();
325333

@@ -421,7 +429,8 @@ bool SILPerformanceInliner::isProfitableToInline(
421429
if (BAI->hasNoNestedConflict() &&
422430
(storage.isUniquelyIdentified() ||
423431
storage.getKind() == AccessedStorage::Class)) {
424-
BlockW.updateBenefit(ExclusivityBenefitWeight, ExclusivityBenefit);
432+
BlockW.updateBenefit(ExclusivityBenefitWeight,
433+
ExclusivityBenefitBase);
425434
} else {
426435
AllAccessesBeneficialToInline = false;
427436
}

0 commit comments

Comments
 (0)