Skip to content

Commit aedc4fe

Browse files
committed
[CSOptimizer] Remove selectBestBindingDisjunction hack
1 parent b936900 commit aedc4fe

File tree

1 file changed

+0
-60
lines changed

1 file changed

+0
-60
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,63 +1342,6 @@ static void determineBestChoicesInContext(
13421342
}
13431343
}
13441344

1345-
// Attempt to find a disjunction of bind constraints where all options
1346-
// in the disjunction are binding the same type variable.
1347-
//
1348-
// Prefer disjunctions where the bound type variable is also the
1349-
// right-hand side of a conversion constraint, since having a concrete
1350-
// type that we're converting to can make it possible to split the
1351-
// constraint system into multiple ones.
1352-
static Constraint *
1353-
selectBestBindingDisjunction(ConstraintSystem &cs,
1354-
SmallVectorImpl<Constraint *> &disjunctions) {
1355-
1356-
if (disjunctions.empty())
1357-
return nullptr;
1358-
1359-
auto getAsTypeVar = [&cs](Type type) {
1360-
return cs.simplifyType(type)->getRValueType()->getAs<TypeVariableType>();
1361-
};
1362-
1363-
Constraint *firstBindDisjunction = nullptr;
1364-
for (auto *disjunction : disjunctions) {
1365-
auto choices = disjunction->getNestedConstraints();
1366-
assert(!choices.empty());
1367-
1368-
auto *choice = choices.front();
1369-
if (choice->getKind() != ConstraintKind::Bind)
1370-
continue;
1371-
1372-
// We can judge disjunction based on the single choice
1373-
// because all of choices (of bind overload set) should
1374-
// have the same left-hand side.
1375-
// Only do this for simple type variable bindings, not for
1376-
// bindings like: ($T1) -> $T2 bind String -> Int
1377-
auto *typeVar = getAsTypeVar(choice->getFirstType());
1378-
if (!typeVar)
1379-
continue;
1380-
1381-
if (!firstBindDisjunction)
1382-
firstBindDisjunction = disjunction;
1383-
1384-
auto constraints = cs.getConstraintGraph().gatherNearbyConstraints(
1385-
typeVar, [](Constraint *constraint) {
1386-
return constraint->getKind() == ConstraintKind::Conversion;
1387-
});
1388-
1389-
for (auto *constraint : constraints) {
1390-
if (typeVar == getAsTypeVar(constraint->getSecondType()))
1391-
return disjunction;
1392-
}
1393-
}
1394-
1395-
// If we had any binding disjunctions, return the first of
1396-
// those. These ensure that we attempt to bind types earlier than
1397-
// trying the elements of other disjunctions, which can often mean
1398-
// we fail faster.
1399-
return firstBindDisjunction;
1400-
}
1401-
14021345
/// Prioritize `build{Block, Expression, ...}` and any chained
14031346
/// members that are connected to individual builder elements
14041347
/// i.e. `ForEach(...) { ... }.padding(...)`, once `ForEach`
@@ -1486,9 +1429,6 @@ ConstraintSystem::selectDisjunction() {
14861429
if (disjunctions.empty())
14871430
return std::nullopt;
14881431

1489-
if (auto *disjunction = selectBestBindingDisjunction(*this, disjunctions))
1490-
return std::make_pair(disjunction, llvm::TinyPtrVector<Constraint *>());
1491-
14921432
llvm::DenseMap<Constraint *, DisjunctionInfo> favorings;
14931433
determineBestChoicesInContext(*this, disjunctions, favorings);
14941434

0 commit comments

Comments
 (0)