17
17
#include " swift/SIL/MemAccessUtils.h"
18
18
#include " swift/SIL/OptimizationRemark.h"
19
19
#include " swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h"
20
+ #include " swift/SILOptimizer/Analysis/IsSelfRecursiveAnalysis.h"
20
21
#include " swift/SILOptimizer/PassManager/Passes.h"
21
22
#include " swift/SILOptimizer/PassManager/Transforms.h"
22
23
#include " swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
@@ -107,6 +108,7 @@ class SILPerformanceInliner {
107
108
DominanceAnalysis *DA;
108
109
SILLoopAnalysis *LA;
109
110
BasicCalleeAnalysis *BCA;
111
+ IsSelfRecursiveAnalysis *SRA;
110
112
111
113
// For keys of SILFunction and SILLoop.
112
114
llvm::DenseMap<SILFunction *, ShortestPathAnalysis *> SPAs;
@@ -238,14 +240,14 @@ class SILPerformanceInliner {
238
240
239
241
public:
240
242
SILPerformanceInliner (StringRef PassName, SILOptFunctionBuilder &FuncBuilder,
241
- InlineSelection WhatToInline,
242
- SILPassManager *pm, DominanceAnalysis *DA,
243
- PostDominanceAnalysis *PDA,
243
+ InlineSelection WhatToInline, SILPassManager *pm,
244
+ DominanceAnalysis *DA, PostDominanceAnalysis *PDA,
244
245
SILLoopAnalysis *LA, BasicCalleeAnalysis *BCA,
245
- OptimizationMode OptMode, OptRemark::Emitter &ORE)
246
+ IsSelfRecursiveAnalysis *SRA, OptimizationMode OptMode,
247
+ OptRemark::Emitter &ORE)
246
248
: PassName(PassName), FuncBuilder(FuncBuilder),
247
- WhatToInline (WhatToInline), pm(pm), DA(DA), LA(LA), BCA(BCA), CBI(DA, PDA), ORE(ORE ),
248
- OptMode(OptMode) {}
249
+ WhatToInline (WhatToInline), pm(pm), DA(DA), LA(LA), BCA(BCA), SRA(SRA ),
250
+ CBI(DA, PDA), ORE(ORE), OptMode(OptMode) {}
249
251
250
252
bool inlineCallsIntoFunction (SILFunction *F);
251
253
};
@@ -1087,7 +1089,7 @@ void SILPerformanceInliner::collectAppliesToInline(
1087
1089
// At this occasion we record additional weight increases.
1088
1090
addWeightCorrection (FAS, WeightCorrections);
1089
1091
1090
- if (SILFunction *Callee = getEligibleFunction (FAS, WhatToInline)) {
1092
+ if (SILFunction *Callee = getEligibleFunction (FAS, WhatToInline, SRA )) {
1091
1093
// Compute the shortest-path analysis for the callee.
1092
1094
SILLoopInfo *CalleeLI = LA->get (Callee);
1093
1095
ShortestPathAnalysis *CalleeSPA = getSPA (Callee, CalleeLI);
@@ -1138,7 +1140,7 @@ void SILPerformanceInliner::collectAppliesToInline(
1138
1140
1139
1141
FullApplySite AI = FullApplySite (&*I);
1140
1142
1141
- auto *Callee = getEligibleFunction (AI, WhatToInline);
1143
+ auto *Callee = getEligibleFunction (AI, WhatToInline, SRA );
1142
1144
if (Callee) {
1143
1145
// Check if we have an always_inline or transparent function. If we do,
1144
1146
// just add it to our final Applies list and continue.
@@ -1328,7 +1330,7 @@ void SILPerformanceInliner::visitColdBlocks(
1328
1330
if (!AI)
1329
1331
continue ;
1330
1332
1331
- auto *Callee = getEligibleFunction (AI, WhatToInline);
1333
+ auto *Callee = getEligibleFunction (AI, WhatToInline, SRA );
1332
1334
if (Callee && decideInColdBlock (AI, Callee, numCallerBlocks)) {
1333
1335
AppliesToInline.push_back (AI);
1334
1336
}
@@ -1358,6 +1360,7 @@ class SILPerformanceInlinerPass : public SILFunctionTransform {
1358
1360
PostDominanceAnalysis *PDA = PM->getAnalysis <PostDominanceAnalysis>();
1359
1361
SILLoopAnalysis *LA = PM->getAnalysis <SILLoopAnalysis>();
1360
1362
BasicCalleeAnalysis *BCA = PM->getAnalysis <BasicCalleeAnalysis>();
1363
+ IsSelfRecursiveAnalysis *SRA = PM->getAnalysis <IsSelfRecursiveAnalysis>();
1361
1364
OptRemark::Emitter ORE (DEBUG_TYPE, *getFunction ());
1362
1365
1363
1366
if (getOptions ().InlineThreshold == 0 ) {
@@ -1369,7 +1372,8 @@ class SILPerformanceInlinerPass : public SILFunctionTransform {
1369
1372
SILOptFunctionBuilder FuncBuilder (*this );
1370
1373
1371
1374
SILPerformanceInliner Inliner (getID (), FuncBuilder, WhatToInline,
1372
- getPassManager (), DA, PDA, LA, BCA, OptMode, ORE);
1375
+ getPassManager (), DA, PDA, LA, BCA, SRA,
1376
+ OptMode, ORE);
1373
1377
1374
1378
assert (getFunction ()->isDefinition () &&
1375
1379
" Expected only functions with bodies!" );
0 commit comments