@@ -2317,12 +2317,14 @@ UpcastInst *UpcastInst::create(SILDebugLocation DebugLoc, SILValue Operand,
2317
2317
2318
2318
ThinToThickFunctionInst *
2319
2319
ThinToThickFunctionInst::create (SILDebugLocation DebugLoc, SILValue Operand,
2320
- SILType Ty, SILFunction & F,
2320
+ SILType Ty, SILModule &Mod, SILFunction * F,
2321
2321
SILOpenedArchetypesState &OpenedArchetypes) {
2322
- SILModule &Mod = F.getModule ();
2323
2322
SmallVector<SILValue, 8 > TypeDependentOperands;
2324
- collectTypeDependentOperands (TypeDependentOperands, OpenedArchetypes, F,
2325
- Ty.getASTType ());
2323
+ if (F) {
2324
+ assert (&F->getModule () == &Mod);
2325
+ collectTypeDependentOperands (TypeDependentOperands, OpenedArchetypes, *F,
2326
+ Ty.getASTType ());
2327
+ }
2326
2328
unsigned size =
2327
2329
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size ());
2328
2330
void *Buffer = Mod.allocateInst (size, alignof (ThinToThickFunctionInst));
@@ -2346,12 +2348,15 @@ PointerToThinFunctionInst::create(SILDebugLocation DebugLoc, SILValue Operand,
2346
2348
}
2347
2349
2348
2350
ConvertFunctionInst *ConvertFunctionInst::create (
2349
- SILDebugLocation DebugLoc, SILValue Operand, SILType Ty, SILFunction &F,
2351
+ SILDebugLocation DebugLoc, SILValue Operand, SILType Ty, SILModule &Mod,
2352
+ SILFunction *F,
2350
2353
SILOpenedArchetypesState &OpenedArchetypes, bool WithoutActuallyEscaping) {
2351
- SILModule &Mod = F.getModule ();
2352
2354
SmallVector<SILValue, 8 > TypeDependentOperands;
2353
- collectTypeDependentOperands (TypeDependentOperands, OpenedArchetypes, F,
2354
- Ty.getASTType ());
2355
+ if (F) {
2356
+ assert (&F->getModule () == &Mod);
2357
+ collectTypeDependentOperands (TypeDependentOperands, OpenedArchetypes, *F,
2358
+ Ty.getASTType ());
2359
+ }
2355
2360
unsigned size =
2356
2361
totalSizeToAlloc<swift::Operand>(1 + TypeDependentOperands.size ());
2357
2362
void *Buffer = Mod.allocateInst (size, alignof (ConvertFunctionInst));
@@ -2362,14 +2367,14 @@ ConvertFunctionInst *ConvertFunctionInst::create(
2362
2367
//
2363
2368
// *NOTE* We purposely do not use an early return here to ensure that in
2364
2369
// builds without assertions this whole if statement is optimized out.
2365
- if (F. getModule () .getStage () != SILStage::Lowered) {
2370
+ if (Mod .getStage () != SILStage::Lowered) {
2366
2371
// Make sure we are not performing ABI-incompatible conversions.
2367
2372
CanSILFunctionType opTI =
2368
2373
CFI->getOperand ()->getType ().castTo <SILFunctionType>();
2369
2374
(void )opTI;
2370
2375
CanSILFunctionType resTI = CFI->getType ().castTo <SILFunctionType>();
2371
2376
(void )resTI;
2372
- assert (opTI->isABICompatibleWith (resTI, F).isCompatible () &&
2377
+ assert ((!F || opTI->isABICompatibleWith (resTI, * F).isCompatible () ) &&
2373
2378
" Can not convert in between ABI incompatible function types" );
2374
2379
}
2375
2380
return CFI;
0 commit comments