Skip to content

Commit 9faa2e5

Browse files
committed
WIP
1 parent c22e046 commit 9faa2e5

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

lib/AST/Decl.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8973,17 +8973,24 @@ bool IsFunctionBodySkippedRequest::evaluate(
89738973
if (isa<ClangModuleUnit>(afd->getDeclContext()->getModuleScopeContext()))
89748974
return false;
89758975

8976-
if (auto *AD = dyn_cast<AccessorDecl>(afd)) {
8976+
if (auto *accessor = dyn_cast<AccessorDecl>(afd)) {
89778977
// didSet accessors needs to be checked to determine whether to keep their
89788978
// parameters.
8979-
if (AD->getAccessorKind() == AccessorKind::DidSet)
8979+
if (accessor->getAccessorKind() == AccessorKind::DidSet)
89808980
return false;
89818981

89828982
// Synthesized accessors with forced static dispatch are emitted on-demand
89838983
// and are serialized. Since they are serialized we must be willing to
89848984
// typecheck them.
8985-
if (AD->hasForcedStaticDispatch())
8985+
if (accessor->hasForcedStaticDispatch())
89868986
return false;
8987+
8988+
if (auto *varDecl = dyn_cast<VarDecl>(accessor->getStorage())) {
8989+
// FIXME: If we don't typecheck the synthesized accessors of lazy storage
8990+
// properties then SILGen crashes when emitting the initializer.
8991+
if (varDecl->getAttrs().hasAttribute<LazyAttr>() && accessor->isSynthesized())
8992+
return false;
8993+
}
89878994
}
89888995

89898996
// Actor initializers need to be checked to determine delegation status.

lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ static bool shouldHaveSkippedFunction(const SILFunction &F) {
7373

7474
if (AD->hasForcedStaticDispatch())
7575
return false;
76+
77+
// ALLANXXX
78+
// if (auto *varDecl = dyn_cast<VarDecl>(accessor->getStorage())) {
79+
// if (varDecl->isLazyStorageProperty() && accessor->isSynthesized())
80+
// return false;
81+
// }
7682
}
7783

7884
// Functions with @backDeployed may be copied into the client, so they

test/SILGen/skip-function-bodies-clang-enum-init-raw-value.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
// CHECK-SKIP-ALL-NOT: sSo7YesOrNoV8rawValueABSgs6UInt32V_tcfC
1818

19-
// CHECK: sil shared [serialized]{{.*}} @$sSo7YesOrNoV8rawValueABSgs6UInt32V_tcfC : $@convention(method) (UInt32, @thin YesOrNo.Type) -> Optional<YesOrNo> {
19+
// CHECK: sil shared [serialized]{{.*}} @$sSo7YesOrNoV8rawValueABSgs6UInt32V_tcfC : $@convention(method) ({{.*}}, @thin YesOrNo.Type) -> Optional<YesOrNo> {
2020
// CHECK: return {{%.*}} : $Optional<YesOrNo>
2121
// CHECK: } // end sil function '$sSo7YesOrNoV8rawValueABSgs6UInt32V_tcfC'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-silgen %s -experimental-skip-non-inlinable-function-bodies | %FileCheck %s
3+
// RUN: %target-swift-frontend -emit-silgen %s -experimental-skip-non-inlinable-function-bodies-without-types | %FileCheck %s
4+
// RUN: %target-swift-frontend -emit-silgen %s -experimental-skip-all-function-bodies | %FileCheck %s --check-prefix=CHECK-SKIP-ALL
5+
6+
// CHECK: sil
7+
8+
// CHECK-SKIP-ALL-NOT: ALLANXXX
9+
10+
public struct S {
11+
public var notLazy = 1
12+
public lazy var x: Int = generateNumber()
13+
14+
func generateNumber() -> Int {
15+
return 1
16+
}
17+
}

0 commit comments

Comments
 (0)