@@ -197,16 +197,23 @@ class SILBuilder {
197
197
assert (F && " cannot create this instruction without a function context" );
198
198
return *F;
199
199
}
200
+
201
+ TypeExpansionContext getTypeExpansionContext () const {
202
+ return TypeExpansionContext (getFunction ());
203
+ }
204
+
200
205
SILBuilderContext &getBuilderContext () const { return C; }
201
206
SILModule &getModule () const { return C.Module ; }
202
207
ASTContext &getASTContext () const { return getModule ().getASTContext (); }
203
208
const Lowering::TypeLowering &getTypeLowering (SILType T) const {
204
- auto expansion = ResilienceExpansion::Maximal;
209
+
210
+ auto expansion = TypeExpansionContext::maximal (getModule ().getSwiftModule (),
211
+ getModule ().isWholeModule ());
205
212
// If there's no current SILFunction, we're inserting into a global
206
213
// variable initializer.
207
- if (F)
208
- expansion = F-> getResilienceExpansion ( );
209
-
214
+ if (F) {
215
+ expansion = TypeExpansionContext ( getFunction () );
216
+ }
210
217
return getModule ().Types .getTypeLowering (T, expansion);
211
218
}
212
219
@@ -336,12 +343,11 @@ class SILBuilder {
336
343
// Type remapping
337
344
// ===--------------------------------------------------------------------===//
338
345
339
- static SILType
340
- getPartialApplyResultType (SILType Ty, unsigned ArgCount, SILModule &M,
341
- SubstitutionMap subs,
342
- ParameterConvention calleeConvention,
343
- PartialApplyInst::OnStackKind onStack =
344
- PartialApplyInst::OnStackKind::NotOnStack);
346
+ static SILType getPartialApplyResultType (
347
+ TypeExpansionContext context, SILType Ty, unsigned ArgCount, SILModule &M,
348
+ SubstitutionMap subs, ParameterConvention calleeConvention,
349
+ PartialApplyInst::OnStackKind onStack =
350
+ PartialApplyInst::OnStackKind::NotOnStack);
345
351
346
352
// ===--------------------------------------------------------------------===//
347
353
// CFG Manipulation
@@ -574,7 +580,8 @@ class SILBuilder {
574
580
FunctionRefBaseInst *createFunctionRefFor (SILLocation Loc, SILFunction *f) {
575
581
if (f->isDynamicallyReplaceable ())
576
582
return createDynamicFunctionRef (Loc, f);
577
- else return createFunctionRef (Loc, f);
583
+ else
584
+ return createFunctionRef (Loc, f);
578
585
}
579
586
580
587
FunctionRefBaseInst *createFunctionRef (SILLocation Loc, SILFunction *f,
@@ -590,37 +597,37 @@ class SILBuilder {
590
597
}
591
598
592
599
FunctionRefInst *createFunctionRef (SILLocation Loc, SILFunction *f) {
593
- return insert (new (getModule ())
594
- FunctionRefInst ( getSILDebugLocation (Loc), f ));
600
+ return insert (new (getModule ()) FunctionRefInst ( getSILDebugLocation (Loc), f,
601
+ getTypeExpansionContext () ));
595
602
}
596
603
597
604
DynamicFunctionRefInst *
598
605
createDynamicFunctionRef (SILLocation Loc, SILFunction *f) {
599
606
return insert (new (getModule ()) DynamicFunctionRefInst (
600
- getSILDebugLocation (Loc), f));
607
+ getSILDebugLocation (Loc), f, getTypeExpansionContext () ));
601
608
}
602
609
603
610
PreviousDynamicFunctionRefInst *
604
611
createPreviousDynamicFunctionRef (SILLocation Loc, SILFunction *f) {
605
612
return insert (new (getModule ()) PreviousDynamicFunctionRefInst (
606
- getSILDebugLocation (Loc), f));
613
+ getSILDebugLocation (Loc), f, getTypeExpansionContext () ));
607
614
}
608
615
609
616
AllocGlobalInst *createAllocGlobal (SILLocation Loc, SILGlobalVariable *g) {
610
617
return insert (new (getModule ())
611
618
AllocGlobalInst (getSILDebugLocation (Loc), g));
612
619
}
613
620
GlobalAddrInst *createGlobalAddr (SILLocation Loc, SILGlobalVariable *g) {
614
- return insert (new (getModule ())
615
- GlobalAddrInst ( getSILDebugLocation (Loc), g ));
621
+ return insert (new (getModule ()) GlobalAddrInst ( getSILDebugLocation (Loc), g,
622
+ getTypeExpansionContext () ));
616
623
}
617
624
GlobalAddrInst *createGlobalAddr (SILLocation Loc, SILType Ty) {
618
625
return insert (new (F->getModule ())
619
626
GlobalAddrInst (getSILDebugLocation (Loc), Ty));
620
627
}
621
628
GlobalValueInst *createGlobalValue (SILLocation Loc, SILGlobalVariable *g) {
622
- return insert (new (getModule ())
623
- GlobalValueInst ( getSILDebugLocation (Loc), g ));
629
+ return insert (new (getModule ()) GlobalValueInst ( getSILDebugLocation (Loc), g,
630
+ getTypeExpansionContext () ));
624
631
}
625
632
IntegerLiteralInst *createIntegerLiteral (IntegerLiteralExpr *E);
626
633
@@ -1285,8 +1292,8 @@ class SILBuilder {
1285
1292
UncheckedEnumDataInst *createUncheckedEnumData (SILLocation Loc,
1286
1293
SILValue Operand,
1287
1294
EnumElementDecl *Element) {
1288
- SILType EltType =
1289
- Operand-> getType (). getEnumElementType ( Element, getModule ());
1295
+ SILType EltType = Operand-> getType (). getEnumElementType (
1296
+ Element, getModule (), getTypeExpansionContext ());
1290
1297
return createUncheckedEnumData (Loc, Operand, Element, EltType);
1291
1298
}
1292
1299
@@ -1307,8 +1314,8 @@ class SILBuilder {
1307
1314
UncheckedTakeEnumDataAddrInst *
1308
1315
createUncheckedTakeEnumDataAddr (SILLocation Loc, SILValue Operand,
1309
1316
EnumElementDecl *Element) {
1310
- SILType EltType =
1311
- Operand-> getType (). getEnumElementType ( Element, getModule ());
1317
+ SILType EltType = Operand-> getType (). getEnumElementType (
1318
+ Element, getModule (), getTypeExpansionContext ());
1312
1319
return createUncheckedTakeEnumDataAddr (Loc, Operand, Element, EltType);
1313
1320
}
1314
1321
@@ -1383,7 +1390,8 @@ class SILBuilder {
1383
1390
1384
1391
StructExtractInst *createStructExtract (SILLocation Loc, SILValue Operand,
1385
1392
VarDecl *Field) {
1386
- auto type = Operand->getType ().getFieldType (Field, getModule ());
1393
+ auto type = Operand->getType ().getFieldType (Field, getModule (),
1394
+ getTypeExpansionContext ());
1387
1395
return createStructExtract (Loc, Operand, Field, type);
1388
1396
}
1389
1397
@@ -1397,7 +1405,8 @@ class SILBuilder {
1397
1405
1398
1406
StructElementAddrInst *
1399
1407
createStructElementAddr (SILLocation Loc, SILValue Operand, VarDecl *Field) {
1400
- auto ResultTy = Operand->getType ().getFieldType (Field, getModule ());
1408
+ auto ResultTy = Operand->getType ().getFieldType (Field, getModule (),
1409
+ getTypeExpansionContext ());
1401
1410
return createStructElementAddr (Loc, Operand, Field, ResultTy);
1402
1411
}
1403
1412
@@ -1408,7 +1417,8 @@ class SILBuilder {
1408
1417
}
1409
1418
RefElementAddrInst *createRefElementAddr (SILLocation Loc, SILValue Operand,
1410
1419
VarDecl *Field) {
1411
- auto ResultTy = Operand->getType ().getFieldType (Field, getModule ());
1420
+ auto ResultTy = Operand->getType ().getFieldType (Field, getModule (),
1421
+ getTypeExpansionContext ());
1412
1422
return createRefElementAddr (Loc, Operand, Field, ResultTy);
1413
1423
}
1414
1424
@@ -2131,7 +2141,8 @@ class SILBuilder {
2131
2141
2132
2142
SILValue emitStructExtract (SILLocation Loc, SILValue Operand,
2133
2143
VarDecl *Field) {
2134
- auto type = Operand->getType ().getFieldType (Field, getModule ());
2144
+ auto type = Operand->getType ().getFieldType (Field, getModule (),
2145
+ getTypeExpansionContext ());
2135
2146
return emitStructExtract (Loc, Operand, Field, type);
2136
2147
}
2137
2148
0 commit comments