Skip to content

Commit 6af5876

Browse files
committed
PerformanceInliner: add the @_semantics("optimize.sil.inline.aggressive") attribute to enable inlining into large functions.
This attribute overrides the limit of maximum number of basic blocks in the caller.
1 parent a022457 commit 6af5876

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

docs/HighLevelSILOptimizations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ optimize.sil.specialize.owned2guarantee.never
412412
Disable function signature optimization which converts an "owned" to a
413413
"guaranteed" function parameter.
414414

415+
optimize.sil.inline.aggressive
416+
417+
Inlines into this function more aggressively than it would be done without
418+
this attribute.
419+
415420
Availability checks
416421
~~~~~~~~~~~~~~~~~~~
417422

include/swift/AST/SemanticAttrs.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_SIZE_NEVER,
7575
"optimize.sil.specialize.generic.size.never")
7676
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_OWNED2GUARANTEE_NEVER,
7777
"optimize.sil.specialize.owned2guarantee.never")
78+
SEMANTICS_ATTR(OPTIMIZE_SIL_INLINE_AGGRESSIVE,
79+
"optimize.sil.inline.aggressive")
7880

7981
// To be used on a nominal type declaration.
8082
// Assumes that a class (or class references inside a nominal type) are immortal.

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,8 @@ void SILPerformanceInliner::collectAppliesToInline(
11531153
// but we /do/ inline any inline_always functions remaining.
11541154
if (NumCallerBlocks > OverallCallerBlockLimit &&
11551155
// Still allow inlining of small functions.
1156-
!hasMaxNumberOfBasicBlocks(Callee, 8)) {
1156+
!hasMaxNumberOfBasicBlocks(Callee, 8) &&
1157+
!Caller->hasSemanticsAttr(semantics::OPTIMIZE_SIL_INLINE_AGGRESSIVE)) {
11571158
continue;
11581159
}
11591160

0 commit comments

Comments
 (0)