Skip to content

Commit a200333

Browse files
committed
SILGen: Skip emitting distributed thunks for skipped functions.
1 parent 8ca4314 commit a200333

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,11 @@ void SILGenModule::emitAbstractFuncDecl(AbstractFunctionDecl *AFD) {
13891389
}
13901390

13911391
if (auto thunkDecl = AFD->getDistributedThunk()) {
1392-
auto thunk = SILDeclRef(thunkDecl).asDistributed();
1393-
emitFunctionDefinition(SILDeclRef(thunkDecl).asDistributed(),
1394-
getFunction(thunk, ForDefinition));
1392+
if (!thunkDecl->isBodySkipped()) {
1393+
auto thunk = SILDeclRef(thunkDecl).asDistributed();
1394+
emitFunctionDefinition(SILDeclRef(thunkDecl).asDistributed(),
1395+
getFunction(thunk, ForDefinition));
1396+
}
13951397
}
13961398

13971399
if (AFD->isBackDeployed(M.getASTContext())) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %target-swift-emit-silgen %s -enable-experimental-distributed -disable-availability-checking -debug-forbid-typecheck-prefix NEVER_TYPECHECK -experimental-skip-non-inlinable-function-bodies | %FileCheck %s --check-prefixes=CHECK,CHECK-SKIP-NONINLINE
2+
// RUN: %target-swift-emit-silgen %s -enable-experimental-distributed -disable-availability-checking -debug-forbid-typecheck-prefix NEVER_TYPECHECK -debug-forbid-typecheck-prefix SKIP_ALL_NO_TYPECHECK -experimental-skip-all-function-bodies | %FileCheck %s --check-prefixes=CHECK,CHECK-SKIP-ALL
3+
4+
// REQUIRES: concurrency
5+
// REQUIRES: distributed
6+
7+
import Distributed
8+
9+
public distributed actor DA {
10+
public typealias ActorSystem = LocalTestingDistributedActorSystem
11+
}
12+
13+
@inline(never)
14+
public func blackHole<T>(_ t: T) { }
15+
16+
extension DA {
17+
18+
// CHECK-NOT: s38distributed_thunk_skip_function_bodies2DAC10publicFuncyyYaKFTE
19+
public distributed func publicFunc() {
20+
let NEVER_TYPECHECK = 1
21+
blackHole(NEVER_TYPECHECK)
22+
}
23+
24+
// CHECK-SKIP-ALL-NOT: s38distributed_thunk_skip_function_bodies2DAC13inlinableFuncyyF
25+
26+
// CHECK-SKIP-NONINLINE-LABEL: sil [serialized] [distributed] [ossa] @$s38distributed_thunk_skip_function_bodies2DAC13inlinableFuncyyF : $@convention(method) (@guaranteed DA) -> () {
27+
// CHECK-SKIP-NONINLINE: function_ref @$s38distributed_thunk_skip_function_bodies9blackHoleyyxlF
28+
// CHECK-SKIP-NONINLINE: } // end sil function '$s38distributed_thunk_skip_function_bodies2DAC13inlinableFuncyyF'
29+
@inlinable public distributed func inlinableFunc() {
30+
let SKIP_ALL_NO_TYPECHECK = 1
31+
blackHole(SKIP_ALL_NO_TYPECHECK)
32+
}
33+
}

0 commit comments

Comments
 (0)