Skip to content

Commit 7197f63

Browse files
committed
Comment LifetimeDependenceScopeFixup. Explain unreachable paths.
1 parent 9953b1e commit 7197f63

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,9 @@ extension ScopeExtension {
744744

745745
// Append each scope that needs extension to scopesToExtend from the inner to the outer scope.
746746
for extScope in scopes.reversed() {
747-
// An outer scope might not originally cover one of its inner scopes. Therefore, extend 'extendedUseRange' to to
748-
// cover this scope's end instructions. The extended scope must at least cover the original scopes because the
749-
// original scopes may protect other operations.
750747
var mustExtend = false
748+
// Iterating over scopeEndInst ignores unreachable paths which may not include the dealloc_stack. This is fine
749+
// because the stack allocation effectively covers the entire unreachable path.
751750
for scopeEndInst in extScope.endInstructions {
752751
switch extendedUseRange.overlaps(pathBegin: extScope.firstInstruction, pathEnd: scopeEndInst, context) {
753752
case .containsPath, .containsEnd, .disjoint:
@@ -757,6 +756,10 @@ extension ScopeExtension {
757756
break
758757
case .containsBegin, .overlappedByPath:
759758
// containsBegin can occur when the extendable scope has the same begin as the use range.
759+
//
760+
// An outer scope might not originally cover one of its inner scopes. Therefore, extend 'extendedUseRange' to
761+
// to cover this scope's end instructions. The extended scope must at least cover the original scopes because
762+
// the original scopes may protect other operations.
760763
extendedUseRange.insert(scopeEndInst)
761764
break
762765
}

0 commit comments

Comments
 (0)