Skip to content

[ConstraintSystem] Remove LinkedExprAnalyzer #40786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ namespace swift {
unsigned SolverShrinkUnsolvedThreshold = 10;

/// Disable the shrink phase of the expression type checker.
bool SolverDisableShrink = false;
bool SolverDisableShrink = true;

/// Enable experimental operator designated types feature.
bool EnableOperatorDesignatedTypes = false;
Expand Down
36 changes: 12 additions & 24 deletions include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,7 @@ class ConstraintSystem {
friend class SplitterStep;
friend class ComponentStep;
friend class TypeVariableStep;
friend class DisjunctionStep;
friend class ConjunctionStep;
friend class ConjunctionElement;
friend class RequirementFailure;
Expand Down Expand Up @@ -2402,6 +2403,10 @@ class ConstraintSystem {
/// the current constraint system.
llvm::MapVector<ConstraintLocator *, unsigned> DisjunctionChoices;

/// The stack of all disjunctions selected during current path in order.
/// This stack is managed by the \c DisjunctionStep.
llvm::SmallVector<Constraint *, 4> SelectedDisjunctions;

/// A map from applied disjunction constraints to the corresponding
/// argument function type.
llvm::SmallMapVector<ConstraintLocator *, const FunctionType *, 4>
Expand Down Expand Up @@ -5023,6 +5028,9 @@ class ConstraintSystem {
///
/// \returns The selected disjunction.
Constraint *selectDisjunction();
/// Select the best possible disjunction for solver to attempt
/// based on the given list.
Constraint *selectBestDisjunction(ArrayRef<Constraint *> disjunctions);

/// Pick a conjunction from the InactiveConstraints list.
///
Expand Down Expand Up @@ -5622,6 +5630,10 @@ class DisjunctionChoice {
bool isSymmetricOperator() const;
bool isUnaryOperator() const;

bool isGenericUnaryOperator() const {
return isGenericOperator() && isUnaryOperator();
}

void print(llvm::raw_ostream &Out, SourceManager *SM) const {
Out << "disjunction choice ";
Choice->print(Out, SM);
Expand Down Expand Up @@ -5839,8 +5851,6 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {

unsigned Index = 0;

bool needsGenericOperatorOrdering = true;

public:
using Element = DisjunctionChoice;

Expand All @@ -5858,10 +5868,6 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
partitionDisjunction(Ordering, PartitionBeginning);
}

void setNeedsGenericOperatorOrdering(bool flag) {
needsGenericOperatorOrdering = flag;
}

Optional<Element> operator()() override {
if (isExhausted())
return None;
Expand All @@ -5874,18 +5880,6 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {

++Index;

auto choice = DisjunctionChoice(CS, currIndex, Choices[Ordering[currIndex]],
IsExplicitConversion, isBeginningOfPartition);
// Partition the generic operators before producing the first generic
// operator disjunction choice.
if (needsGenericOperatorOrdering && choice.isGenericOperator()) {
unsigned nextPartitionIndex = (PartitionIndex < PartitionBeginning.size() ?
PartitionBeginning[PartitionIndex] : Ordering.size());
partitionGenericOperators(Ordering.begin() + currIndex,
Ordering.begin() + nextPartitionIndex);
needsGenericOperatorOrdering = false;
}

return DisjunctionChoice(CS, currIndex, Choices[Ordering[currIndex]],
IsExplicitConversion, isBeginningOfPartition);
}
Expand All @@ -5900,12 +5894,6 @@ class DisjunctionChoiceProducer : public BindingProducer<DisjunctionChoice> {
// have to visit all of the options.
void partitionDisjunction(SmallVectorImpl<unsigned> &Ordering,
SmallVectorImpl<unsigned> &PartitionBeginning);

/// Partition the choices in the range \c first to \c last into groups and
/// order the groups in the best order to attempt based on the argument
/// function type that the operator is applied to.
void partitionGenericOperators(SmallVectorImpl<unsigned>::iterator first,
SmallVectorImpl<unsigned>::iterator last);
};

class ConjunctionElementProducer : public BindingProducer<ConjunctionElement> {
Expand Down
Loading