Skip to content

Commit 0c446c4

Browse files
authored
Merge pull request #8104 from rjmccall/farewell-to-archetype-access-paths
IRGen's archetype access path hack is now dead code, RIP. NFC.
2 parents 789bb5b + 720481d commit 0c446c4

File tree

4 files changed

+0
-131
lines changed

4 files changed

+0
-131
lines changed

lib/IRGen/GenArchetype.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ namespace irgen {
3535
using GetTypeParameterInContextFn =
3636
llvm::function_ref<CanType(CanType type)>;
3737

38-
void bindArchetypeAccessPaths(IRGenFunction &IGF,
39-
GenericSignature *generics,
40-
GetTypeParameterInContextFn getInContext);
41-
4238
/// Emit a type metadata reference for an archetype.
4339
llvm::Value *emitArchetypeTypeMetadataRef(IRGenFunction &IGF,
4440
CanArchetypeType archetype);

lib/IRGen/GenMeta.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,18 +2789,6 @@ irgen::emitFieldTypeAccessor(IRGenModule &IGM,
27892789
// use it to provide metadata for generic parameters in field types.
27902790
IGF.bindLocalTypeDataFromTypeMetadata(formalType, IsExact, metadata);
27912791

2792-
// Bind archetype access paths if the type is generic.
2793-
if (type->isGenericContext()) {
2794-
auto declCtxt = type;
2795-
if (auto generics = declCtxt->getGenericSignatureOfContext()) {
2796-
auto getInContext = [&](CanType type) -> CanType {
2797-
return declCtxt->mapTypeIntoContext(type)
2798-
->getCanonicalType();
2799-
};
2800-
bindArchetypeAccessPaths(IGF, generics, getInContext);
2801-
}
2802-
}
2803-
28042792
// Allocate storage for the field vector.
28052793
unsigned allocSize = fieldTypes.size() * IGM.getPointerSize().getValue();
28062794
auto allocSizeVal = llvm::ConstantInt::get(IGM.IntPtrTy, allocSize);

lib/IRGen/GenProto.cpp

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,16 +1222,6 @@ class AccessorConformanceInfo : public ConformanceInfo {
12221222
}
12231223
return *Fulfillments;
12241224
}
1225-
1226-
void bindArchetypeAccessPathsInConformance(IRGenFunction &IGF) {
1227-
auto declCtx = Conformance.getDeclContext();
1228-
if (auto generics = declCtx->getGenericSignatureOfContext()) {
1229-
auto getInContext = [&](CanType type) -> CanType {
1230-
return declCtx->mapTypeIntoContext(type)->getCanonicalType();
1231-
};
1232-
bindArchetypeAccessPaths(IGF, generics, getInContext);
1233-
}
1234-
}
12351225
};
12361226
} // end anonymous namespace
12371227

@@ -1286,9 +1276,6 @@ getAssociatedTypeMetadataAccessFunction(AssociatedTypeDecl *requirement,
12861276
// Bind local type data from the metadata argument.
12871277
IGF.bindLocalTypeDataFromTypeMetadata(ConcreteType, IsExact, self);
12881278

1289-
// Bind archetype access paths.
1290-
bindArchetypeAccessPathsInConformance(IGF);
1291-
12921279
// For now, assume that an associated type is cheap enough to access
12931280
// that it doesn't need a new cache entry.
12941281
if (auto archetype = dyn_cast<ArchetypeType>(associatedType)) {
@@ -1426,9 +1413,6 @@ getAssociatedTypeWitnessTableAccessFunction(CanType depAssociatedType,
14261413
associatedTypeMetadata);
14271414
IGF.bindLocalTypeDataFromTypeMetadata(ConcreteType, IsExact, self);
14281415

1429-
// Bind archetype access paths.
1430-
bindArchetypeAccessPathsInConformance(IGF);
1431-
14321416
// For now, assume that finding an abstract conformance is always
14331417
// fast enough that it's not worth caching.
14341418
// TODO: provide an API to find the best metadata path to the conformance
@@ -1787,58 +1771,6 @@ bool irgen::hasPolymorphicParameters(CanSILFunctionType ty) {
17871771
llvm_unreachable("Not a valid SILFunctionTypeRepresentation.");
17881772
}
17891773

1790-
static
1791-
void addPotentialArchetypeAccessPath(IRGenFunction &IGF,
1792-
CanType targetDepType,
1793-
CanType sourceDepType,
1794-
GetTypeParameterInContextFn getInContext) {
1795-
assert(targetDepType->isTypeParameter());
1796-
assert(sourceDepType->isTypeParameter());
1797-
1798-
// We can only break down an associated-type path.
1799-
auto sourceDepMemberType = dyn_cast<DependentMemberType>(sourceDepType);
1800-
if (!sourceDepMemberType) return;
1801-
1802-
// We only really need to do this when there's a non-trivial set of
1803-
// conformances, but we can't determine that just from this decl:
1804-
// the associated type might gain conformances in a refining protocol.
1805-
auto association = sourceDepMemberType->getAssocType();
1806-
1807-
// These can end up as non-archetypes because of multiple levels of
1808-
// equality.
1809-
auto destArchetype =
1810-
dyn_cast<ArchetypeType>(getInContext(targetDepType));
1811-
if (!destArchetype) return;
1812-
auto srcBaseArchetype =
1813-
dyn_cast<ArchetypeType>(getInContext(sourceDepMemberType.getBase()));
1814-
if (!srcBaseArchetype) return;
1815-
1816-
IGF.addArchetypeAccessPath(destArchetype,
1817-
{srcBaseArchetype, association});
1818-
}
1819-
1820-
void irgen::bindArchetypeAccessPaths(IRGenFunction &IGF, GenericSignature *Generics,
1821-
GetTypeParameterInContextFn getInContext) {
1822-
// Remember all the extra ways we have of reaching the parameter
1823-
// archetypes due to type equality constraints.
1824-
for (auto reqt : Generics->getRequirements()) {
1825-
// Ignore non-same-type requirements in this pass.
1826-
if (reqt.getKind() != RequirementKind::SameType) continue;
1827-
1828-
// Ignore equality constraints to concrete types. This is really
1829-
// just a fast-path; we still have to handle this case later.
1830-
// TODO: This might be a faster / better-cached way to materialize
1831-
// local type data for the concrete type.
1832-
if (!reqt.getSecondType()->isTypeParameter()) continue;
1833-
1834-
auto firstType = reqt.getFirstType()->getCanonicalType();
1835-
auto secondType = reqt.getSecondType()->getCanonicalType();
1836-
1837-
addPotentialArchetypeAccessPath(IGF, firstType, secondType, getInContext);
1838-
addPotentialArchetypeAccessPath(IGF, secondType, firstType, getInContext);
1839-
}
1840-
}
1841-
18421774
/// Emit a polymorphic parameters clause, binding all the metadata necessary.
18431775
void EmitPolymorphicParameters::emit(Explosion &in,
18441776
WitnessMetadata *witnessMetadata,
@@ -1860,29 +1792,8 @@ void EmitPolymorphicParameters::emit(Explosion &in,
18601792

18611793
// Bind all the fulfillments we can from the formal parameters.
18621794
bindParameterSources(getParameter);
1863-
1864-
if (!Generics) return;
1865-
1866-
// Bind all the archetype access paths.
1867-
bindArchetypeAccessPaths(IGF, Generics, getInContext);
1868-
}
1869-
1870-
void IRGenFunction::addArchetypeAccessPath(CanArchetypeType targetArchetype,
1871-
ArchetypeAccessPath accessPath) {
1872-
ArchetypeAccessPaths[targetArchetype].push_back(accessPath);
18731795
}
18741796

1875-
ArrayRef<IRGenFunction::ArchetypeAccessPath>
1876-
IRGenFunction::getArchetypeAccessPaths(CanArchetypeType targetArchetype) {
1877-
auto it = ArchetypeAccessPaths.find(targetArchetype);
1878-
if (it == ArchetypeAccessPaths.end()) {
1879-
return {};
1880-
} else {
1881-
return it->second;
1882-
}
1883-
}
1884-
1885-
18861797
llvm::Value *
18871798
MetadataPath::followFromTypeMetadata(IRGenFunction &IGF,
18881799
CanType sourceType,
@@ -2716,12 +2627,6 @@ void GenericTypeRequirements::bindFromBuffer(IRGenFunction &IGF,
27162627
Address buffer,
27172628
GetTypeParameterInContextFn getInContext) {
27182629
bindFromGenericRequirementsBuffer(IGF, Requirements, buffer, getInContext);
2719-
2720-
auto Generics = TheDecl->getGenericSignature();
2721-
if (!Generics) return;
2722-
2723-
// Bind all the archetype access paths in the signature's requirements.
2724-
bindArchetypeAccessPaths(IGF, Generics, getInContext);
27252630
}
27262631

27272632
void irgen::bindFromGenericRequirementsBuffer(IRGenFunction &IGF,

lib/IRGen/IRGenFunction.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -394,23 +394,6 @@ class IRGenFunction {
394394
llvm::Value *metadata,
395395
ArrayRef<llvm::Value*> wtables);
396396

397-
struct ArchetypeAccessPath {
398-
CanArchetypeType BaseType;
399-
AssociatedTypeDecl *Association;
400-
};
401-
402-
/// Register an additional access path to the given archetype besides
403-
/// (if applicable) just drilling down from its parent.
404-
///
405-
/// This is necessary when an archetype gains conformances from an
406-
/// associated type that it's been constrained to be equal to
407-
/// but which is not simply its parent.
408-
void addArchetypeAccessPath(CanArchetypeType targetArchetype,
409-
ArchetypeAccessPath accessPath);
410-
411-
ArrayRef<ArchetypeAccessPath>
412-
getArchetypeAccessPaths(CanArchetypeType targetArchetype);
413-
414397
//--- Type emission ------------------------------------------------------------
415398
public:
416399
/// Look up a local type data reference, returning null if no entry was
@@ -581,9 +564,6 @@ class IRGenFunction {
581564
llvm::Value *LocalSelf = nullptr;
582565

583566
LocalSelfKind SelfKind;
584-
585-
llvm::DenseMap<CanType, std::vector<ArchetypeAccessPath>>
586-
ArchetypeAccessPaths;
587567
};
588568

589569
using ConditionalDominanceScope = IRGenFunction::ConditionalDominanceScope;

0 commit comments

Comments
 (0)