Skip to content

Commit cce30cc

Browse files
committed
SIL: Remove SILFunction::mapTypeOutOfContext()
1 parent f07cde7 commit cce30cc

File tree

11 files changed

+20
-38
lines changed

11 files changed

+20
-38
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,6 @@ class SILFunction
648648
/// SILFunction.
649649
SILType mapTypeIntoContext(SILType type) const;
650650

651-
/// Map the given type, which is based on a contextual SILFunctionType and may
652-
/// therefore contain context archetypes, to an interface type.
653-
Type mapTypeOutOfContext(Type type) const;
654-
655651
/// Converts the given function definition to a declaration.
656652
void convertToDeclaration();
657653

lib/IRGen/GenReflection.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -555,21 +555,19 @@ class BoxDescriptorBuilder : public ReflectionMetadataBuilder {
555555
/// captures are generic.
556556
class CaptureDescriptorBuilder : public ReflectionMetadataBuilder {
557557
swift::reflection::MetadataSourceBuilder SourceBuilder;
558-
SILFunction &Caller;
559558
CanSILFunctionType OrigCalleeType;
560559
CanSILFunctionType SubstCalleeType;
561560
SubstitutionList Subs;
562561
const HeapLayout &Layout;
563562

564563
public:
565564
CaptureDescriptorBuilder(IRGenModule &IGM,
566-
SILFunction &Caller,
567565
CanSILFunctionType OrigCalleeType,
568566
CanSILFunctionType SubstCalleeType,
569567
SubstitutionList Subs,
570568
const HeapLayout &Layout)
571569
: ReflectionMetadataBuilder(IGM),
572-
Caller(Caller), OrigCalleeType(OrigCalleeType),
570+
OrigCalleeType(OrigCalleeType),
573571
SubstCalleeType(SubstCalleeType), Subs(Subs),
574572
Layout(Layout) {}
575573

@@ -650,7 +648,7 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder {
650648

651649
auto Source = SourceBuilder.createClosureBinding(i);
652650
auto BindingType = Bindings[i].TypeParameter;
653-
auto InterfaceType = Caller.mapTypeOutOfContext(BindingType);
651+
auto InterfaceType = BindingType->mapTypeOutOfContext();
654652
SourceMap.push_back({InterfaceType->getCanonicalType(), Source});
655653
}
656654

@@ -692,7 +690,7 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder {
692690
auto Src = Path.getMetadataSource(SourceBuilder, Root);
693691

694692
auto SubstType = GenericParam.subst(SubstMap);
695-
auto InterfaceType = Caller.mapTypeOutOfContext(SubstType);
693+
auto InterfaceType = SubstType->mapTypeOutOfContext();
696694
SourceMap.push_back({InterfaceType->getCanonicalType(), Src});
697695
});
698696

@@ -718,7 +716,7 @@ class CaptureDescriptorBuilder : public ReflectionMetadataBuilder {
718716
})->getCanonicalType();
719717
}
720718

721-
auto InterfaceType = Caller.mapTypeOutOfContext(SwiftType);
719+
auto InterfaceType = SwiftType->mapTypeOutOfContext();
722720
CaptureTypes.push_back(InterfaceType->getCanonicalType());
723721
}
724722

@@ -864,7 +862,7 @@ IRGenModule::getAddrOfCaptureDescriptor(SILFunction &Caller,
864862
if (CaptureDescriptorBuilder::hasOpenedExistential(OrigCalleeType, Layout))
865863
return llvm::Constant::getNullValue(CaptureDescriptorPtrTy);
866864

867-
CaptureDescriptorBuilder builder(*this, Caller,
865+
CaptureDescriptorBuilder builder(*this,
868866
OrigCalleeType, SubstCalleeType, Subs,
869867
Layout);
870868
auto var = builder.emit();

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,8 +3148,7 @@ void IRGenSILFunction::visitRetainValueAddrInst(swift::RetainValueAddrInst *i) {
31483148
llvm::Type *llvmType = addr.getAddress()->getType();
31493149
const TypeInfo &addrTI = getTypeInfo(addrTy);
31503150
auto *outlinedF = IGM.getOrCreateRetainFunction(
3151-
addrTI, i->getFunction()
3152-
->mapTypeOutOfContext(objectT.getSwiftRValueType())
3151+
addrTI, objectT.getSwiftRValueType()->mapTypeOutOfContext()
31533152
->getCanonicalType(),
31543153
llvmType);
31553154
llvm::Value *args[] = {addr.getAddress()};
@@ -3227,8 +3226,7 @@ void IRGenSILFunction::visitReleaseValueAddrInst(
32273226
llvm::Type *llvmType = addr.getAddress()->getType();
32283227
const TypeInfo &addrTI = getTypeInfo(addrTy);
32293228
auto *outlinedF = IGM.getOrCreateReleaseFunction(
3230-
addrTI, i->getFunction()
3231-
->mapTypeOutOfContext(objectT.getSwiftRValueType())
3229+
addrTI, objectT.getSwiftRValueType()->mapTypeOutOfContext()
32323230
->getCanonicalType(),
32333231
llvmType);
32343232
llvm::Value *args[] = {addr.getAddress()};

lib/SIL/SILFunction.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,6 @@ SILType GenericEnvironment::mapTypeIntoContext(SILModule &M,
204204
genericSig);
205205
}
206206

207-
Type SILFunction::mapTypeOutOfContext(Type type) const {
208-
return type->mapTypeOutOfContext();
209-
}
210-
211207
bool SILFunction::isNoReturnFunction() const {
212208
return SILType::getPrimitiveObjectType(getLoweredFunctionType())
213209
.isNoReturnFunction();

lib/SILGen/SILGen.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
217217
/// Get or create the declaration of a reabstraction thunk with the
218218
/// given signature.
219219
SILFunction *getOrCreateReabstractionThunk(
220-
GenericEnvironment *genericEnv,
221220
CanSILFunctionType thunkType,
222221
CanSILFunctionType fromType,
223222
CanSILFunctionType toType,

lib/SILGen/SILGenBridging.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
507507
// Build the invoke function signature. The block will capture the original
508508
// function value.
509509
auto fnInterfaceTy = cast<SILFunctionType>(
510-
F.mapTypeOutOfContext(loweredFuncTy)->getCanonicalType());
510+
loweredFuncTy->mapTypeOutOfContext()->getCanonicalType());
511511
auto blockInterfaceTy = cast<SILFunctionType>(
512-
F.mapTypeOutOfContext(loweredBlockTy)->getCanonicalType());
512+
loweredBlockTy->mapTypeOutOfContext()->getCanonicalType());
513513

514514
assert(!blockInterfaceTy->isCoroutine());
515515

@@ -557,8 +557,7 @@ ManagedValue SILGenFunction::emitFuncToBlock(SILLocation loc,
557557

558558
// Create the invoke function. Borrow the mangling scheme from reabstraction
559559
// thunks, which is what we are in spirit.
560-
auto thunk = SGM.getOrCreateReabstractionThunk(genericEnv,
561-
invokeTy,
560+
auto thunk = SGM.getOrCreateReabstractionThunk(invokeTy,
562561
loweredFuncTy,
563562
loweredBlockTy,
564563
F.isSerialized());
@@ -873,8 +872,7 @@ SILGenFunction::emitBlockToFunc(SILLocation loc,
873872
inputSubstType, outputSubstType,
874873
genericEnv, interfaceSubs);
875874

876-
auto thunk = SGM.getOrCreateReabstractionThunk(genericEnv,
877-
thunkTy,
875+
auto thunk = SGM.getOrCreateReabstractionThunk(thunkTy,
878876
loweredBlockTy,
879877
loweredFuncTy,
880878
F.isSerialized());

lib/SILGen/SILGenExpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3658,7 +3658,7 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
36583658
bool needsGenericContext = false;
36593659
if (rootTy->hasArchetype()) {
36603660
needsGenericContext = true;
3661-
rootTy = SGF.F.mapTypeOutOfContext(rootTy)->getCanonicalType();
3661+
rootTy = rootTy->mapTypeOutOfContext()->getCanonicalType();
36623662
}
36633663

36643664
auto baseTy = rootTy;
@@ -3766,7 +3766,7 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
37663766
baseSubscriptTy = genSubscriptTy
37673767
->substGenericArgs(component.getDeclRef().getSubstitutions());
37683768
auto baseSubscriptInterfaceTy = cast<AnyFunctionType>(
3769-
SGF.F.mapTypeOutOfContext(baseSubscriptTy)->getCanonicalType());
3769+
baseSubscriptTy->mapTypeOutOfContext()->getCanonicalType());
37703770

37713771
baseTy = baseSubscriptInterfaceTy.getResult();
37723772

@@ -3793,10 +3793,10 @@ RValue RValueEmitter::visitKeyPathExpr(KeyPathExpr *E, SGFContext C) {
37933793
hashable.getConcrete()->getType()->isEqual(indexValues[i].getType()));
37943794
auto &value = indexValues[i];
37953795

3796-
auto indexTy = SGF.F.mapTypeOutOfContext(value.getType())->getCanonicalType();
3796+
auto indexTy = value.getType()->mapTypeOutOfContext()->getCanonicalType();
37973797
auto indexLoweredTy = SGF.getLoweredType(value.getType());
37983798
indexLoweredTy = SILType::getPrimitiveType(
3799-
SGF.F.mapTypeOutOfContext(indexLoweredTy.getSwiftRValueType())
3799+
indexLoweredTy.getSwiftRValueType()->mapTypeOutOfContext()
38003800
->getCanonicalType(),
38013801
indexLoweredTy.getCategory());
38023802
indexPatterns.push_back({(unsigned)operands.size(),

lib/SILGen/SILGenPoly.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,6 @@ static ManagedValue createThunk(SILGenFunction &SGF,
29032903
genericEnv,
29042904
interfaceSubs);
29052905
auto thunk = SGF.SGM.getOrCreateReabstractionThunk(
2906-
genericEnv,
29072906
thunkType,
29082907
sourceType,
29092908
toType,

lib/SILGen/SILGenThunk.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ SILValue SILGenFunction::emitGlobalFunctionRef(SILLocation loc,
357357
}
358358

359359
SILFunction *SILGenModule::
360-
getOrCreateReabstractionThunk(GenericEnvironment *genericEnv,
361-
CanSILFunctionType thunkType,
360+
getOrCreateReabstractionThunk(CanSILFunctionType thunkType,
362361
CanSILFunctionType fromType,
363362
CanSILFunctionType toType,
364363
IsSerialized_t Serialized) {

lib/SILOptimizer/IPO/CapturePropagation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,13 @@ void CapturePropagationCloner::cloneBlocks(
214214
}
215215

216216
CanSILFunctionType getPartialApplyInterfaceResultType(PartialApplyInst *PAI) {
217-
SILFunction *OrigF = PAI->getReferencedFunction();
218217
// The new partial_apply will no longer take any arguments--they are all
219218
// expressed as literals. So its callee signature will be the same as its
220219
// return signature.
221220
auto FTy = PAI->getType().castTo<SILFunctionType>();
222221
assert(!PAI->hasSubstitutions() || !hasArchetypes(PAI->getSubstitutions()));
223222
FTy = cast<SILFunctionType>(
224-
OrigF->mapTypeOutOfContext(FTy)->getCanonicalType());
223+
FTy->mapTypeOutOfContext()->getCanonicalType());
225224
auto NewFTy = FTy;
226225
return NewFTy;
227226
}

0 commit comments

Comments
 (0)