Skip to content

Commit 41ff738

Browse files
committed
IRGen: Clean up opaque type specialization wrappers
1 parent 12ce32e commit 41ff738

File tree

5 files changed

+21
-40
lines changed

5 files changed

+21
-40
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,8 +3761,8 @@ llvm::Value *irgen::emitWitnessTableRef(IRGenFunction &IGF,
37613761

37623762
// Look through any opaque types we're allowed to.
37633763
if (srcType->hasOpaqueArchetype()) {
3764-
std::tie(srcType, conformance) =
3765-
IGF.IGM.substOpaqueTypesWithUnderlyingTypes(srcType, conformance);
3764+
srcType = IGF.IGM.substOpaqueTypesWithUnderlyingTypes(srcType);
3765+
conformance = IGF.IGM.substOpaqueTypesWithUnderlyingTypes(conformance);
37663766
}
37673767

37683768
// If we don't have concrete conformance information, the type must be

lib/IRGen/GenReflection.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,7 @@ std::pair<llvm::Constant *, unsigned>
583583
IRGenModule::getLoweredTypeRef(SILType loweredType,
584584
CanGenericSignature genericSig,
585585
MangledTypeRefRole role) {
586-
auto substTy =
587-
substOpaqueTypesWithUnderlyingTypes(loweredType, genericSig);
586+
auto substTy = substOpaqueTypesWithUnderlyingTypes(loweredType);
588587
auto type = substTy.getASTType();
589588
return getTypeRefImpl(*this, type, genericSig, role);
590589
}
@@ -600,8 +599,8 @@ IRGenModule::emitWitnessTableRefString(CanType type,
600599
ProtocolConformanceRef conformance,
601600
GenericSignature origGenericSig,
602601
bool shouldSetLowBit) {
603-
std::tie(type, conformance)
604-
= substOpaqueTypesWithUnderlyingTypes(type, conformance);
602+
type = substOpaqueTypesWithUnderlyingTypes(type);
603+
conformance = substOpaqueTypesWithUnderlyingTypes(conformance);
605604

606605
auto origType = type;
607606
auto genericSig = origGenericSig.getCanonicalSignature();

lib/IRGen/IRGenModule.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,10 +1162,9 @@ class IRGenModule {
11621162
CanType getRuntimeReifiedType(CanType type);
11631163
Type substOpaqueTypesWithUnderlyingTypes(Type type);
11641164
CanType substOpaqueTypesWithUnderlyingTypes(CanType type);
1165-
SILType substOpaqueTypesWithUnderlyingTypes(SILType type, CanGenericSignature genericSig);
1166-
std::pair<CanType, ProtocolConformanceRef>
1167-
substOpaqueTypesWithUnderlyingTypes(CanType type,
1168-
ProtocolConformanceRef conformance);
1165+
SILType substOpaqueTypesWithUnderlyingTypes(SILType type);
1166+
ProtocolConformanceRef
1167+
substOpaqueTypesWithUnderlyingTypes(ProtocolConformanceRef conformance);
11691168

11701169
bool isResilient(NominalTypeDecl *decl, ResilienceExpansion expansion,
11711170
ClassDecl *asViewedFromRootClass = nullptr);

lib/IRGen/MetadataRequest.cpp

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -494,46 +494,29 @@ CanType IRGenModule::getRuntimeReifiedType(CanType type) {
494494
Type IRGenModule::substOpaqueTypesWithUnderlyingTypes(Type type) {
495495
// Substitute away opaque types whose underlying types we're allowed to
496496
// assume are constant.
497-
if (type->hasOpaqueArchetype()) {
498-
auto context = getMaximalTypeExpansionContext();
499-
return swift::substOpaqueTypesWithUnderlyingTypes(type, context);
500-
}
501-
502-
return type;
497+
auto context = getMaximalTypeExpansionContext();
498+
return swift::substOpaqueTypesWithUnderlyingTypes(type, context);
503499
}
504500

505501
CanType IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type) {
506502
return substOpaqueTypesWithUnderlyingTypes(static_cast<Type>(type))
507503
->getCanonicalType();
508504
}
509505

510-
SILType IRGenModule::substOpaqueTypesWithUnderlyingTypes(
511-
SILType type, CanGenericSignature genericSig) {
506+
SILType IRGenModule::substOpaqueTypesWithUnderlyingTypes(SILType type) {
512507
// Substitute away opaque types whose underlying types we're allowed to
513508
// assume are constant.
514-
if (type.getASTType()->hasOpaqueArchetype()) {
515-
auto context = getMaximalTypeExpansionContext();
516-
return SILType::getPrimitiveType(
517-
swift::substOpaqueTypesWithUnderlyingTypes(type.getASTType(), context),
518-
type.getCategory());
519-
}
520-
521-
return type;
509+
auto context = getMaximalTypeExpansionContext();
510+
return SILType::getPrimitiveType(
511+
swift::substOpaqueTypesWithUnderlyingTypes(type.getASTType(), context),
512+
type.getCategory());
522513
}
523514

524-
std::pair<CanType, ProtocolConformanceRef>
525-
IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type,
526-
ProtocolConformanceRef conformance) {
527-
// Substitute away opaque types whose underlying types we're allowed to
528-
// assume are constant.
529-
if (type->hasOpaqueArchetype()) {
530-
auto context = getMaximalTypeExpansionContext();
531-
return std::make_pair(
532-
swift::substOpaqueTypesWithUnderlyingTypes(type, context),
533-
swift::substOpaqueTypesWithUnderlyingTypes(conformance, context));
534-
}
535-
536-
return std::make_pair(type, conformance);
515+
ProtocolConformanceRef
516+
IRGenModule::substOpaqueTypesWithUnderlyingTypes(
517+
ProtocolConformanceRef conformance) {
518+
auto context = getMaximalTypeExpansionContext();
519+
return swift::substOpaqueTypesWithUnderlyingTypes(conformance, context);
537520
}
538521

539522

lib/IRGen/Outlining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void OutliningMetadataCollector::collectTypeMetadata(SILType ty) {
6868
}
6969

7070
// Substitute opaque types if allowed.
71-
ty = IGF.IGM.substOpaqueTypesWithUnderlyingTypes(ty, CanGenericSignature());
71+
ty = IGF.IGM.substOpaqueTypesWithUnderlyingTypes(ty);
7272

7373
collectTypeMetadataForLayout(ty);
7474
collectTypeMetadataForDeinit(ty);

0 commit comments

Comments
 (0)