Skip to content

Commit f3d5345

Browse files
committed
IRGen: Kill classifyTypeSize(), NFC
1 parent c469b20 commit f3d5345

File tree

3 files changed

+0
-123
lines changed

3 files changed

+0
-123
lines changed

lib/IRGen/GenType.cpp

-108
Original file line numberDiff line numberDiff line change
@@ -1924,114 +1924,6 @@ bool IRGenModule::isPOD(SILType type, ResilienceScope scope) {
19241924
}
19251925

19261926

1927-
namespace {
1928-
struct ClassifyTypeSize : CanTypeVisitor<ClassifyTypeSize, ObjectSize> {
1929-
IRGenModule &IGM;
1930-
ResilienceScope Scope;
1931-
ClassifyTypeSize(IRGenModule &IGM, ResilienceScope scope)
1932-
: IGM(IGM), Scope(scope) {}
1933-
1934-
#define ALWAYS(KIND, RESULT) \
1935-
ObjectSize visit##KIND##Type(KIND##Type *t) { return ObjectSize::RESULT; }
1936-
1937-
ALWAYS(Builtin, Fixed)
1938-
ALWAYS(SILFunction, Fixed)
1939-
ALWAYS(Class, Fixed)
1940-
ALWAYS(BoundGenericClass, Fixed)
1941-
ALWAYS(Protocol, Fixed)
1942-
ALWAYS(ProtocolComposition, Fixed)
1943-
ALWAYS(LValue, Dependent)
1944-
#undef ALWAYS
1945-
1946-
ObjectSize visitArchetypeType(CanArchetypeType archetype) {
1947-
if (archetype->requiresClass())
1948-
return ObjectSize::Fixed;
1949-
return ObjectSize::Dependent;
1950-
}
1951-
1952-
ObjectSize visitTupleType(CanTupleType tuple) {
1953-
ObjectSize result = ObjectSize::Fixed;
1954-
for (auto eltType : tuple.getElementTypes()) {
1955-
result = std::max(result, visit(eltType));
1956-
}
1957-
return result;
1958-
}
1959-
1960-
ObjectSize visitStructType(CanStructType type) {
1961-
if (type->getDecl()->getGenericParamsOfContext())
1962-
return visitGenericStructType(type, type->getDecl());
1963-
if (IGM.isResilient(type->getDecl(), Scope))
1964-
return ObjectSize::Resilient;
1965-
return ObjectSize::Fixed;
1966-
}
1967-
1968-
ObjectSize visitBoundGenericStructType(CanBoundGenericStructType type) {
1969-
return visitGenericStructType(type, type->getDecl());
1970-
}
1971-
1972-
ObjectSize visitGenericStructType(CanType type, StructDecl *D) {
1973-
assert(D->getGenericParamsOfContext());
1974-
1975-
// If a generic struct is resilient, we have to assume that any
1976-
// unknown fields might be dependently-sized.
1977-
if (IGM.isResilient(D, Scope))
1978-
return ObjectSize::Dependent;
1979-
1980-
auto structType = SILType::getPrimitiveAddressType(type);
1981-
1982-
ObjectSize result = ObjectSize::Fixed;
1983-
for (auto field : D->getStoredProperties()) {
1984-
auto fieldType = structType.getFieldType(field, *IGM.SILMod);
1985-
result = std::max(result, visitSILType(fieldType));
1986-
}
1987-
return result;
1988-
}
1989-
1990-
ObjectSize visitEnumType(CanEnumType type) {
1991-
if (type->getDecl()->getGenericParamsOfContext())
1992-
return visitGenericEnumType(type, type->getDecl());
1993-
if (IGM.isResilient(type->getDecl(), Scope))
1994-
return ObjectSize::Resilient;
1995-
return ObjectSize::Fixed;
1996-
}
1997-
1998-
ObjectSize visitBoundGenericEnumType(CanBoundGenericEnumType type) {
1999-
return visitGenericEnumType(type, type->getDecl());
2000-
}
2001-
2002-
ObjectSize visitGenericEnumType(CanType type, EnumDecl *D) {
2003-
assert(D->getGenericParamsOfContext());
2004-
2005-
// If a generic enum is resilient, we have to assume that any
2006-
// unknown elements might be dependently-sized.
2007-
if (IGM.isResilient(D, Scope))
2008-
return ObjectSize::Dependent;
2009-
2010-
auto enumType = SILType::getPrimitiveAddressType(type);
2011-
2012-
ObjectSize result = ObjectSize::Fixed;
2013-
for (auto elt : D->getAllElements()) {
2014-
if (!elt->hasArgumentType()) continue;
2015-
auto eltType = enumType.getEnumElementType(elt, *IGM.SILMod);
2016-
result = std::max(result, visitSILType(eltType));
2017-
}
2018-
return result;
2019-
}
2020-
2021-
ObjectSize visitType(CanType type) {
2022-
return ObjectSize::Fixed;
2023-
}
2024-
2025-
ObjectSize visitSILType(SILType type) {
2026-
return visit(type.getSwiftRValueType());
2027-
}
2028-
};
2029-
}
2030-
2031-
ObjectSize IRGenModule::classifyTypeSize(SILType type, ResilienceScope scope) {
2032-
return ClassifyTypeSize(*this, scope).visitSILType(type);
2033-
}
2034-
20351927
SpareBitVector IRGenModule::getSpareBitsForType(llvm::Type *scalarTy, Size size) {
20361928
auto it = SpareBitsForTypes.find(scalarTy);
20371929
if (it != SpareBitsForTypes.end())

lib/IRGen/IRGen.h

-14
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,6 @@ enum class ResilienceScope {
116116
Universal
117117
};
118118

119-
/// Whether an object is fixed in size or not. This answer is always
120-
/// relative to some resilience scope.
121-
enum class ObjectSize : uint8_t {
122-
/// The object's size is fixed in the resilience scope.
123-
Fixed,
124-
125-
/// The object's size is unknown in the resilience domain, but it is
126-
/// not dependent.
127-
Resilient,
128-
129-
/// The object's size is dependent on a generic parameter.
130-
Dependent
131-
};
132-
133119
/// Destructor variants.
134120
enum class DestructorKind : uint8_t {
135121
/// A deallocating destructor destroys the object and deallocates

lib/IRGen/IRGenModule.h

-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ class IRGenModule {
470470
llvm::PointerType *isSingleIndirectValue(SILType T);
471471
llvm::PointerType *requiresIndirectResult(SILType T);
472472
bool isPOD(SILType type, ResilienceScope scope);
473-
ObjectSize classifyTypeSize(SILType type, ResilienceScope scope);
474473
clang::CanQual<clang::Type> getClangType(CanType type);
475474
clang::CanQual<clang::Type> getClangType(SILType type);
476475
clang::CanQual<clang::Type> getClangType(SILParameterInfo param);

0 commit comments

Comments
 (0)