File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -9495,6 +9495,12 @@ bool IsFunctionBodySkippedRequest::evaluate(
94959495 skippingMode == FunctionBodySkipping::NonInlinableWithoutTypes)
94969496 return false ;
94979497
9498+ // Don't skip functions that follow a top-level guard statement.
9499+ if (afd->getDeclContext ()->isModuleScopeContext () &&
9500+ isa<FuncDecl>(afd) &&
9501+ cast<FuncDecl>(afd)->hasTopLevelLocalContextCaptures ())
9502+ return false ;
9503+
94989504 // Skip functions that don't need to be serialized.
94999505 return afd->getResilienceExpansion () != ResilienceExpansion::Minimal;
95009506}
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend -experimental-skip-non-inlinable-function-bodies-without-types -emit-module %s
2+
3+ let s : Int ? = nil
4+ guard let m = s else { fatalError ( ) }
5+
6+ let x = m
7+
8+ public func f( _: Int = m, _: String = " " ) { }
9+
10+ f ( )
Original file line number Diff line number Diff line change 55guard let x: Int = nil else { while true { } }
66
77// CHECK-LABEL: sil hidden [ossa] @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> () {
8- // SKIPPED-FUNC-EMITTED-LABEL-NOT : sil hidden [ossa] @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> () {
8+ // SKIPPED-FUNC-EMITTED-LABEL: sil hidden [ossa] @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> () {
99func capturesX( ) {
1010 _ = x
1111}
1212
1313// CHECK-LABEL: sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
1414// CHECK: [[FUNC:%.*]] = function_ref @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> ()
15- // SKIPPED-FUNC-EMITTED-LABEL-NOT : sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
16- // SKIPPED-FUNC-EMITTED-NOT : [[FUNC:%.*]] = function_ref @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> ()
15+ // SKIPPED-FUNC-EMITTED-LABEL: sil hidden [ossa] @$s18top_level_captures17transitiveCaptureyyF : $@convention(thin) (Int) -> () {
16+ // SKIPPED-FUNC-EMITTED: [[FUNC:%.*]] = function_ref @$s18top_level_captures0C1XyyF : $@convention(thin) (Int) -> ()
1717func transitiveCapture( ) {
1818 capturesX ( )
1919}
You can’t perform that action at this time.
0 commit comments