Skip to content

Commit d7c389e

Browse files
authored
Merge pull request #5372 from apple/revert-5265-wip-generics-inlining-flag
Revert "[sil-performance-inliner] Re-introduce inlining of generics as a staging feature behind a flag"
2 parents 4d35bce + dc2777e commit d7c389e

File tree

1 file changed

+6
-48
lines changed

1 file changed

+6
-48
lines changed

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "swift/SILOptimizer/PassManager/Passes.h"
1515
#include "swift/SILOptimizer/PassManager/Transforms.h"
1616
#include "swift/SILOptimizer/Utils/PerformanceInlinerUtils.h"
17-
#include "swift/Strings.h"
1817
#include "llvm/ADT/Statistic.h"
1918
#include "llvm/Support/Debug.h"
2019
#include "llvm/Support/CommandLine.h"
@@ -27,10 +26,6 @@ llvm::cl::opt<bool> PrintShortestPathInfo(
2726
"print-shortest-path-info", llvm::cl::init(false),
2827
llvm::cl::desc("Print shortest-path information for inlining"));
2928

30-
llvm::cl::opt<bool> EnableSILInliningOfGenerics(
31-
"sil-inline-generics", llvm::cl::init(false),
32-
llvm::cl::desc("Enable inlining of generics"));
33-
3429
//===----------------------------------------------------------------------===//
3530
// Performance Inliner
3631
//===----------------------------------------------------------------------===//
@@ -127,11 +122,6 @@ class SILPerformanceInliner {
127122
ConstantTracker &constTracker,
128123
int &NumCallerBlocks);
129124

130-
bool isProfitableToInlineGeneric(FullApplySite AI,
131-
Weight CallerWeight,
132-
ConstantTracker &constTracker,
133-
int &NumCallerBlocks);
134-
135125
bool isProfitableInColdBlock(FullApplySite AI, SILFunction *Callee);
136126

137127
void visitColdBlocks(SmallVectorImpl<FullApplySite> &AppliesToInline,
@@ -201,6 +191,10 @@ SILFunction *SILPerformanceInliner::getEligibleFunction(FullApplySite AI) {
201191
return nullptr;
202192
}
203193

194+
// We don't support this yet.
195+
if (AI.hasSubstitutions())
196+
return nullptr;
197+
204198
SILFunction *Caller = AI.getFunction();
205199

206200
// We don't support inlining a function that binds dynamic self because we
@@ -375,37 +369,6 @@ bool SILPerformanceInliner::isProfitableToInlineNonGeneric(FullApplySite AI,
375369
return true;
376370
}
377371

378-
/// Return true if inlining this call site is profitable.
379-
bool SILPerformanceInliner::isProfitableToInlineGeneric(FullApplySite AI,
380-
Weight CallerWeight,
381-
ConstantTracker &callerTracker,
382-
int &NumCallerBlocks) {
383-
assert(!AI.getSubstitutions().empty() &&
384-
"Expected a generic apply");
385-
386-
SILFunction *Callee = AI.getReferencedFunction();
387-
388-
// Do not inline @_semantics functions when compiling the stdlib,
389-
// because they need to be preserved, so that the optimizer
390-
// can properly optimize a user code later.
391-
auto ModuleName = Callee->getModule().getSwiftModule()->getName().str();
392-
if (Callee->hasSemanticsAttrThatStartsWith("array.") &&
393-
(ModuleName == STDLIB_NAME || ModuleName == SWIFT_ONONE_SUPPORT))
394-
return false;
395-
396-
// Always inline generic functions which are marked as
397-
// AlwaysInline or transparent.
398-
bool ShouldInline = Callee->getInlineStrategy() == AlwaysInline ||
399-
Callee->isTransparent();
400-
401-
// Only inline if we decided to inline or we are asked to inline all
402-
// generic functions.
403-
if (ShouldInline || EnableSILInliningOfGenerics)
404-
return true;
405-
406-
return false;
407-
}
408-
409372
/// Return true if inlining this call site into a cold block is profitable.
410373
bool SILPerformanceInliner::isProfitableInColdBlock(FullApplySite AI,
411374
SILFunction *Callee) {
@@ -519,13 +482,8 @@ void SILPerformanceInliner::collectAppliesToInline(
519482
// The actual weight including a possible weight correction.
520483
Weight W(BlockWeight, WeightCorrections.lookup(AI));
521484

522-
bool IsGenericApply = !AI.getSubstitutions().empty();
523-
bool IsProfitableToInline =
524-
IsGenericApply ? isProfitableToInlineGeneric(AI, W, constTracker,
525-
NumCallerBlocks)
526-
: isProfitableToInlineNonGeneric(AI, W, constTracker,
527-
NumCallerBlocks);
528-
485+
bool IsProfitableToInline = isProfitableToInlineNonGeneric(
486+
AI, W, constTracker, NumCallerBlocks);
529487
if (IsProfitableToInline)
530488
InitialCandidates.push_back(AI);
531489
}

0 commit comments

Comments
 (0)