Skip to content

Commit f744af1

Browse files
author
Joe Shajrawi
authored
Merge pull request #21897 from shajrawi/excl_inline
[PerformanceInliner] Reduce the code size impact of the exclusivity heuristic
2 parents a628d5d + 18e9256 commit f744af1

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
@@ -38,6 +38,10 @@ llvm::cl::opt<bool> EnableSILInliningOfGenerics(
3838
"sil-inline-generics", llvm::cl::init(false),
3939
llvm::cl::desc("Enable inlining of generics"));
4040

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

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

325333
SubstitutionMap CalleeSubstMap = AI.getSubstitutionMap();
326334

@@ -422,7 +430,8 @@ bool SILPerformanceInliner::isProfitableToInline(
422430
if (BAI->hasNoNestedConflict() &&
423431
(storage.isUniquelyIdentified() ||
424432
storage.getKind() == AccessedStorage::Class)) {
425-
BlockW.updateBenefit(ExclusivityBenefitWeight, ExclusivityBenefit);
433+
BlockW.updateBenefit(ExclusivityBenefitWeight,
434+
ExclusivityBenefitBase);
426435
} else {
427436
AllAccessesBeneficialToInline = false;
428437
}

0 commit comments

Comments
 (0)