Commit 14b110d
committed
Sema: Associated type inference optimization
This addresses a performance regression from 83cb420.
In the old associated type inference implementation, we used to
fold valid solutions by comparing type witnesses, but this was
not correct as described in the commit message there.
After my fix we started to record more valid solutions from the
same search space, and this caused a performance regression
because we were already doing exponential work.
However in the program in question, each possible choice of witness
for a requirement would introduce the same bindings, so there was
nothing to gain from trying them all.
Since ranking only compares pairs of witnesses for the same
requirement, we can optimize this problem another way: by folding
identical terms in a disjunction, but only if *all* terms are
identical, which avoids the correctness issue in the old search
strategy.
Fixes rdar://problem/123334433.1 parent a2a2083 commit 14b110d
File tree
2 files changed
+120
-1
lines changed- lib/Sema
- test/decl/protocol/req
2 files changed
+120
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
578 | 579 | | |
579 | 580 | | |
580 | 581 | | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
581 | 600 | | |
582 | 601 | | |
583 | 602 | | |
| |||
1533 | 1552 | | |
1534 | 1553 | | |
1535 | 1554 | | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
1536 | 1588 | | |
1537 | 1589 | | |
1538 | 1590 | | |
| |||
1743 | 1795 | | |
1744 | 1796 | | |
1745 | 1797 | | |
1746 | | - | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
1747 | 1801 | | |
1748 | 1802 | | |
1749 | 1803 | | |
| |||
3380 | 3434 | | |
3381 | 3435 | | |
3382 | 3436 | | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
3383 | 3440 | | |
3384 | 3441 | | |
3385 | 3442 | | |
| |||
Lines changed: 62 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
0 commit comments