@@ -197,10 +197,9 @@ class ClosureCloner : public SILClonerWithScopes<ClosureCloner> {
197
197
friend class SILInstructionVisitor <ClosureCloner>;
198
198
friend class SILCloner <ClosureCloner>;
199
199
200
- ClosureCloner (SILOptFunctionBuilder &FuncBuilder,
201
- SILFunction *Orig, IsSerialized_t Serialized,
202
- StringRef ClonedName,
203
- IndicesSet &PromotableIndices);
200
+ ClosureCloner (SILOptFunctionBuilder &FuncBuilder, SILFunction *Orig,
201
+ IsSerialized_t Serialized, StringRef ClonedName,
202
+ IndicesSet &PromotableIndices, ResilienceExpansion expansion);
204
203
205
204
void populateCloned ();
206
205
@@ -210,7 +209,8 @@ class ClosureCloner : public SILClonerWithScopes<ClosureCloner> {
210
209
static SILFunction *initCloned (SILOptFunctionBuilder &FuncBuilder,
211
210
SILFunction *Orig, IsSerialized_t Serialized,
212
211
StringRef ClonedName,
213
- IndicesSet &PromotableIndices);
212
+ IndicesSet &PromotableIndices,
213
+ ResilienceExpansion expansion);
214
214
215
215
SILValue getProjectBoxMappedVal (SILValue Operand);
216
216
@@ -224,6 +224,7 @@ class ClosureCloner : public SILClonerWithScopes<ClosureCloner> {
224
224
void visitBeginAccessInst (BeginAccessInst *Inst);
225
225
void visitEndAccessInst (EndAccessInst *Inst);
226
226
227
+ ResilienceExpansion resilienceExpansion;
227
228
SILFunction *Orig;
228
229
IndicesSet &PromotableIndices;
229
230
llvm::DenseMap<SILArgument *, SILValue> BoxArgumentMap;
@@ -311,10 +312,12 @@ ReachabilityInfo::isReachable(SILBasicBlock *From, SILBasicBlock *To) {
311
312
ClosureCloner::ClosureCloner (SILOptFunctionBuilder &FuncBuilder,
312
313
SILFunction *Orig, IsSerialized_t Serialized,
313
314
StringRef ClonedName,
314
- IndicesSet &PromotableIndices)
315
- : SILClonerWithScopes<ClosureCloner>(
316
- *initCloned (FuncBuilder, Orig, Serialized, ClonedName, PromotableIndices)),
317
- Orig(Orig), PromotableIndices(PromotableIndices) {
315
+ IndicesSet &PromotableIndices,
316
+ ResilienceExpansion resilienceExpansion)
317
+ : SILClonerWithScopes<ClosureCloner>(
318
+ *initCloned (FuncBuilder, Orig, Serialized, ClonedName,
319
+ PromotableIndices, resilienceExpansion)),
320
+ Orig(Orig), PromotableIndices(PromotableIndices) {
318
321
assert (Orig->getDebugScope ()->Parent != getCloned ()->getDebugScope ()->Parent );
319
322
}
320
323
@@ -326,9 +329,9 @@ ClosureCloner::ClosureCloner(SILOptFunctionBuilder &FuncBuilder,
326
329
// / 2. Replace container box value arguments for the cloned closure with the
327
330
// / transformed address or value argument.
328
331
static void
329
- computeNewArgInterfaceTypes (SILFunction *F,
330
- IndicesSet &PromotableIndices ,
331
- SmallVectorImpl<SILParameterInfo> &OutTys ) {
332
+ computeNewArgInterfaceTypes (SILFunction *F, IndicesSet &PromotableIndices,
333
+ SmallVectorImpl<SILParameterInfo> &OutTys ,
334
+ ResilienceExpansion expansion ) {
332
335
auto fnConv = F->getConventions ();
333
336
auto Parameters = fnConv.funcTy ->getParameters ();
334
337
@@ -365,11 +368,9 @@ computeNewArgInterfaceTypes(SILFunction *F,
365
368
assert (paramBoxTy->getLayout ()->getFields ().size () == 1
366
369
&& " promoting compound box not implemented yet" );
367
370
auto paramBoxedTy = paramBoxTy->getFieldType (F->getModule (), 0 );
368
- // FIXME: Expansion
369
- auto ¶mTL = Types.getTypeLowering (paramBoxedTy,
370
- ResilienceExpansion::Minimal);
371
+ auto ¶mTL = Types.getTypeLowering (paramBoxedTy, expansion);
371
372
ParameterConvention convention;
372
- if (paramTL.isFormallyPassedIndirectly ()) {
373
+ if (paramTL.isAddressOnly ()) {
373
374
convention = ParameterConvention::Indirect_In;
374
375
} else if (paramTL.isTrivial ()) {
375
376
convention = ParameterConvention::Direct_Unowned;
@@ -407,16 +408,17 @@ static std::string getSpecializedName(SILFunction *F,
407
408
// /
408
409
// / *NOTE* PromotableIndices only contains the container value of the box, not
409
410
// / the address value.
410
- SILFunction*
411
+ SILFunction *
411
412
ClosureCloner::initCloned (SILOptFunctionBuilder &FunctionBuilder,
412
413
SILFunction *Orig, IsSerialized_t Serialized,
413
- StringRef ClonedName,
414
- IndicesSet &PromotableIndices ) {
414
+ StringRef ClonedName, IndicesSet &PromotableIndices,
415
+ ResilienceExpansion resilienceExpansion ) {
415
416
SILModule &M = Orig->getModule ();
416
417
417
418
// Compute the arguments for our new function.
418
419
SmallVector<SILParameterInfo, 4 > ClonedInterfaceArgTys;
419
- computeNewArgInterfaceTypes (Orig, PromotableIndices, ClonedInterfaceArgTys);
420
+ computeNewArgInterfaceTypes (Orig, PromotableIndices, ClonedInterfaceArgTys,
421
+ resilienceExpansion);
420
422
421
423
SILFunctionType *OrigFTI = Orig->getLoweredFunctionType ();
422
424
@@ -1149,7 +1151,8 @@ examineAllocBoxInst(AllocBoxInst *ABI, ReachabilityInfo &RI,
1149
1151
static SILFunction *
1150
1152
constructClonedFunction (SILOptFunctionBuilder &FuncBuilder,
1151
1153
PartialApplyInst *PAI, FunctionRefInst *FRI,
1152
- IndicesSet &PromotableIndices) {
1154
+ IndicesSet &PromotableIndices,
1155
+ ResilienceExpansion resilienceExpansion) {
1153
1156
SILFunction *F = PAI->getFunction ();
1154
1157
1155
1158
// Create the Cloned Name for the function.
@@ -1168,7 +1171,8 @@ constructClonedFunction(SILOptFunctionBuilder &FuncBuilder,
1168
1171
}
1169
1172
1170
1173
// Otherwise, create a new clone.
1171
- ClosureCloner cloner (FuncBuilder, Orig, Serialized, ClonedName, PromotableIndices);
1174
+ ClosureCloner cloner (FuncBuilder, Orig, Serialized, ClonedName,
1175
+ PromotableIndices, resilienceExpansion);
1172
1176
cloner.populateCloned ();
1173
1177
return cloner.getCloned ();
1174
1178
}
@@ -1252,7 +1256,8 @@ processPartialApplyInst(SILOptFunctionBuilder &FuncBuilder,
1252
1256
auto *FRI = dyn_cast<FunctionRefInst>(PAI->getCallee ());
1253
1257
1254
1258
// Clone the closure with the given promoted captures.
1255
- SILFunction *ClonedFn = constructClonedFunction (FuncBuilder, PAI, FRI, PromotableIndices);
1259
+ SILFunction *ClonedFn = constructClonedFunction (
1260
+ FuncBuilder, PAI, FRI, PromotableIndices, F->getResilienceExpansion ());
1256
1261
Worklist.push_back (ClonedFn);
1257
1262
1258
1263
// Initialize a SILBuilder and create a function_ref referencing the cloned
0 commit comments