Skip to content

Commit b5e3f42

Browse files
Merge pull request #77044 from nate-chandler/rdar137960229
[DiagnoseUnreachable] Ignore dead_end destroys.
2 parents e4d625c + ce368e8 commit b5e3f42

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/SILOptimizer/Mandatory/DiagnoseUnreachable.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,14 @@ static bool simplifyBlocksWithCallsToNoReturn(SILBasicBlock &BB,
775775
if (isa<EndBorrowInst>(currInst))
776776
return false;
777777

778+
// destroy_value [dead_end] instructions are inserted at the availability
779+
// boundary by lifetime completion. Such instructions correctly mark the
780+
// lifetime boundary of the destroyed value and never arise from dead user
781+
// code.
782+
auto *dvi = dyn_cast<DestroyValueInst>(currInst);
783+
if (dvi && dvi->isDeadEnd())
784+
return false;
785+
778786
// If no-return instruction is not something we can point in code or
779787
// it's an explicit cast, skip it.
780788
if (!noReturnCall->getLoc().is<RegularLocation>() ||
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -c %s -verify
2+
3+
func testFatalError(_ message: @autoclosure () -> String = String()) -> Never {
4+
Swift.fatalError()
5+
}
6+
7+
func test() {
8+
testFatalError()
9+
}

0 commit comments

Comments
 (0)