Commit e239441
committed
[SILOptimizer] Don't diagnose unreachable instructions that belong to no-return func
The pass is attempting to diagnose any user-written code that appears
after the result of no-return function call. It has to skip any
instructions that happen after the no-return call but are associated
with it, such as `alloc_stack` to pass result of such call indirectly.
This helps to avoid extraneous diagnostics for synthesized code i.e.
a result builder with `buildExpression`:
```
static func buildExpression<T>(_ e: T) -> T { e }
```
The following example would produce extraneous warning:
```
switch <value> {
case ...
default: fatalError()
}
```
because it is translated into:
```
switch <value> {
case ...
default: {
var $__builderDefault = buildExpression(fatalError())
$__builderSwitch = buildEither(second: $__builderDefault)
}
}
```
In such cases all instructions that follow `fatalError()` call
are synthesized except to `alloc_stack $Never` which is passed
to `buildExpression`, that instruction is anchored on the
`fatalError()` itself which is where the diagnostic would point,
which is incorrect.
Resolves: rdar://104775183
(cherry picked from commit afaeca7)1 parent 8bd0080 commit e239441
File tree
2 files changed
+92
-20
lines changed- lib/SILOptimizer/Mandatory
- test/SILOptimizer
2 files changed
+92
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
748 | 786 | | |
749 | 787 | | |
750 | 788 | | |
| |||
758 | 796 | | |
759 | 797 | | |
760 | 798 | | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
| 799 | + | |
| 800 | + | |
781 | 801 | | |
782 | 802 | | |
783 | 803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
0 commit comments