Skip to content

Commit 0e72686

Browse files
committed
[CSSolver] Attempt choices marked as disfavored at the end of partition
Since such choices are all but guaranteed to be worst than any other non-disfavored choice, let's attempt them last to avoid having to form a complete solution just to filter it out during ranking.
1 parent 0e0b5f9 commit 0e72686

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,8 @@ void DisjunctionChoiceProducer::partitionDisjunction(
23102310
// end of the partitioning.
23112311
SmallVector<unsigned, 4> favored;
23122312
SmallVector<unsigned, 4> everythingElse;
2313+
// Disfavored choices are part of `everythingElse` but introduced at the end.
2314+
SmallVector<unsigned, 4> disfavored;
23132315
SmallVector<unsigned, 4> simdOperators;
23142316
SmallVector<unsigned, 4> disabled;
23152317
SmallVector<unsigned, 4> unavailable;
@@ -2342,6 +2344,11 @@ void DisjunctionChoiceProducer::partitionDisjunction(
23422344
everythingElse.push_back(index);
23432345
return true;
23442346
}
2347+
2348+
if (decl->getAttrs().hasAttribute<DisfavoredOverloadAttr>()) {
2349+
disfavored.push_back(index);
2350+
return true;
2351+
}
23452352
}
23462353

23472354
return false;
@@ -2385,6 +2392,9 @@ void DisjunctionChoiceProducer::partitionDisjunction(
23852392
return true;
23862393
});
23872394

2395+
// Introduce disfavored choices at the end.
2396+
everythingElse.append(disfavored);
2397+
23882398
// Local function to create the next partition based on the options
23892399
// passed in.
23902400
PartitionAppendCallback appendPartition =

0 commit comments

Comments
 (0)