14
14
#include " swift/SILOptimizer/PassManager/Passes.h"
15
15
#include " swift/SILOptimizer/PassManager/Transforms.h"
16
16
#include " swift/SILOptimizer/Utils/PerformanceInlinerUtils.h"
17
- #include " swift/Strings.h"
18
17
#include " llvm/ADT/Statistic.h"
19
18
#include " llvm/Support/Debug.h"
20
19
#include " llvm/Support/CommandLine.h"
@@ -27,10 +26,6 @@ llvm::cl::opt<bool> PrintShortestPathInfo(
27
26
" print-shortest-path-info" , llvm::cl::init(false ),
28
27
llvm::cl::desc(" Print shortest-path information for inlining" ));
29
28
30
- llvm::cl::opt<bool > EnableSILInliningOfGenerics (
31
- " sil-inline-generics" , llvm::cl::init(false ),
32
- llvm::cl::desc(" Enable inlining of generics" ));
33
-
34
29
// ===----------------------------------------------------------------------===//
35
30
// Performance Inliner
36
31
// ===----------------------------------------------------------------------===//
@@ -127,11 +122,6 @@ class SILPerformanceInliner {
127
122
ConstantTracker &constTracker,
128
123
int &NumCallerBlocks);
129
124
130
- bool isProfitableToInlineGeneric (FullApplySite AI,
131
- Weight CallerWeight,
132
- ConstantTracker &constTracker,
133
- int &NumCallerBlocks);
134
-
135
125
bool isProfitableInColdBlock (FullApplySite AI, SILFunction *Callee);
136
126
137
127
void visitColdBlocks (SmallVectorImpl<FullApplySite> &AppliesToInline,
@@ -201,6 +191,10 @@ SILFunction *SILPerformanceInliner::getEligibleFunction(FullApplySite AI) {
201
191
return nullptr ;
202
192
}
203
193
194
+ // We don't support this yet.
195
+ if (AI.hasSubstitutions ())
196
+ return nullptr ;
197
+
204
198
SILFunction *Caller = AI.getFunction ();
205
199
206
200
// We don't support inlining a function that binds dynamic self because we
@@ -375,37 +369,6 @@ bool SILPerformanceInliner::isProfitableToInlineNonGeneric(FullApplySite AI,
375
369
return true ;
376
370
}
377
371
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
-
409
372
// / Return true if inlining this call site into a cold block is profitable.
410
373
bool SILPerformanceInliner::isProfitableInColdBlock (FullApplySite AI,
411
374
SILFunction *Callee) {
@@ -519,13 +482,8 @@ void SILPerformanceInliner::collectAppliesToInline(
519
482
// The actual weight including a possible weight correction.
520
483
Weight W (BlockWeight, WeightCorrections.lookup (AI));
521
484
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);
529
487
if (IsProfitableToInline)
530
488
InitialCandidates.push_back (AI);
531
489
}
0 commit comments