Skip to content

Commit 2a6f279

Browse files
committed
[ConstraintSystem] NFC: Remove obsolete used/checked conformances cache
1 parent 5f20eb6 commit 2a6f279

File tree

4 files changed

+1
-60
lines changed

4 files changed

+1
-60
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,6 @@ class Solution {
11771177
llvm::SmallMapVector<const CaseLabelItem *, CaseLabelItemInfo, 4>
11781178
caseLabelItems;
11791179

1180-
std::vector<std::pair<ConstraintLocator *, ProtocolConformanceRef>>
1181-
Conformances;
1182-
11831180
/// The set of functions that have been transformed by a result builder.
11841181
llvm::MapVector<AnyFunctionRef, AppliedBuilderTransform>
11851182
resultBuilderTransformed;
@@ -1255,11 +1252,6 @@ class Solution {
12551252
return None;
12561253
}
12571254

1258-
/// Retrieve a fully-resolved protocol conformance at the given locator
1259-
/// and with the given protocol.
1260-
ProtocolConformanceRef resolveConformance(ConstraintLocator *locator,
1261-
ProtocolDecl *proto);
1262-
12631255
ConstraintLocator *getCalleeLocator(ConstraintLocator *locator,
12641256
bool lookThroughApply = true) const;
12651257

@@ -2209,9 +2201,6 @@ class ConstraintSystem {
22092201
/// each node had before introducing this type.
22102202
llvm::SmallVector<std::pair<ASTNode, Type>, 8> addedNodeTypes;
22112203

2212-
std::vector<std::pair<ConstraintLocator *, ProtocolConformanceRef>>
2213-
CheckedConformances;
2214-
22152204
/// The set of functions that have been transformed by a result builder.
22162205
std::vector<std::pair<AnyFunctionRef, AppliedBuilderTransform>>
22172206
resultBuilderTransformed;
@@ -2675,8 +2664,6 @@ class ConstraintSystem {
26752664

26762665
unsigned numAddedNodeTypes;
26772666

2678-
unsigned numCheckedConformances;
2679-
26802667
unsigned numDisabledConstraints;
26812668

26822669
unsigned numFavoredConstraints;
@@ -3885,12 +3872,6 @@ class ConstraintSystem {
38853872
const DeclRefExpr *base = nullptr,
38863873
OpenedTypeMap *replacements = nullptr);
38873874

3888-
/// Retrieve a list of conformances established along the current solver path.
3889-
ArrayRef<std::pair<ConstraintLocator *, ProtocolConformanceRef>>
3890-
getCheckedConformances() const {
3891-
return CheckedConformances;
3892-
}
3893-
38943875
/// Retrieve a list of generic parameter types solver has "opened" (replaced
38953876
/// with a type variable) along the current path.
38963877
ArrayRef<std::pair<ConstraintLocator *, ArrayRef<OpenedType>>>

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8382,34 +8382,6 @@ Expr *Solution::coerceToType(Expr *expr, Type toType,
83828382
return result;
83838383
}
83848384

8385-
ProtocolConformanceRef Solution::resolveConformance(
8386-
ConstraintLocator *locator, ProtocolDecl *proto) {
8387-
auto conformance = llvm::find_if(Conformances, [&locator](const auto &elt) {
8388-
return elt.first == locator;
8389-
});
8390-
8391-
if (conformance == Conformances.end())
8392-
return ProtocolConformanceRef::forInvalid();
8393-
8394-
// If the conformance doesn't require substitution, return it immediately.
8395-
auto conformanceRef = conformance->second;
8396-
if (conformanceRef.isAbstract())
8397-
return conformanceRef;
8398-
8399-
auto concrete = conformanceRef.getConcrete();
8400-
auto conformingType = concrete->getType();
8401-
if (!conformingType->hasTypeVariable())
8402-
return conformanceRef;
8403-
8404-
// Substitute into the conformance type, then look for a conformance
8405-
// again.
8406-
// FIXME: Should be able to perform the substitution using the Solution
8407-
// itself rather than another conforms-to-protocol check.
8408-
Type substConformingType = simplifyType(conformingType);
8409-
return TypeChecker::conformsToProtocol(substConformingType, proto,
8410-
constraintSystem->DC);
8411-
}
8412-
84138385
bool Solution::hasType(ASTNode node) const {
84148386
auto result = nodeTypes.find(node);
84158387
if (result != nodeTypes.end())

lib/Sema/CSSolver.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ Solution ConstraintSystem::finalize() {
185185
solution.solutionApplicationTargets = solutionApplicationTargets;
186186
solution.caseLabelItems = caseLabelItems;
187187

188-
for (auto &e : CheckedConformances)
189-
solution.Conformances.push_back({e.first, e.second});
190-
191188
for (const auto &transformed : resultBuilderTransformed) {
192189
solution.resultBuilderTransformed.insert(transformed);
193190
}
@@ -273,10 +270,6 @@ void ConstraintSystem::applySolution(const Solution &solution) {
273270
setCaseLabelItemInfo(info.first, info.second);
274271
}
275272

276-
// Register the conformances checked along the way to arrive to solution.
277-
for (auto &conformance : solution.Conformances)
278-
CheckedConformances.push_back(conformance);
279-
280273
for (const auto &transformed : solution.resultBuilderTransformed) {
281274
resultBuilderTransformed.push_back(transformed);
282275
}
@@ -477,7 +470,6 @@ ConstraintSystem::SolverScope::SolverScope(ConstraintSystem &cs)
477470
numOpenedExistentialTypes = cs.OpenedExistentialTypes.size();
478471
numDefaultedConstraints = cs.DefaultedConstraints.size();
479472
numAddedNodeTypes = cs.addedNodeTypes.size();
480-
numCheckedConformances = cs.CheckedConformances.size();
481473
numDisabledConstraints = cs.solverState->getNumDisabledConstraints();
482474
numFavoredConstraints = cs.solverState->getNumFavoredConstraints();
483475
numResultBuilderTransformed = cs.resultBuilderTransformed.size();
@@ -555,9 +547,6 @@ ConstraintSystem::SolverScope::~SolverScope() {
555547
}
556548
truncate(cs.addedNodeTypes, numAddedNodeTypes);
557549

558-
// Remove any conformances checked along the current path.
559-
truncate(cs.CheckedConformances, numCheckedConformances);
560-
561550
/// Remove any builder transformed closures.
562551
truncate(cs.resultBuilderTransformed, numResultBuilderTransformed);
563552

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,8 +2903,7 @@ size_t Solution::getTotalMemory() const {
29032903
ConstraintRestrictions.getMemorySize() +
29042904
llvm::capacity_in_bytes(Fixes) + DisjunctionChoices.getMemorySize() +
29052905
OpenedTypes.getMemorySize() + OpenedExistentialTypes.getMemorySize() +
2906-
(DefaultedConstraints.size() * sizeof(void *)) +
2907-
Conformances.size() * sizeof(std::pair<ConstraintLocator *, ProtocolConformanceRef>);
2906+
(DefaultedConstraints.size() * sizeof(void *));
29082907
}
29092908

29102909
DeclContext *Solution::getDC() const { return constraintSystem->DC; }

0 commit comments

Comments
 (0)