File tree Expand file tree Collapse file tree 5 files changed +38
-19
lines changed Expand file tree Collapse file tree 5 files changed +38
-19
lines changed Original file line number Diff line number Diff line change @@ -1416,13 +1416,7 @@ void SILGenModule::emitAbstractFuncDecl(AbstractFunctionDecl *AFD) {
1416
1416
emitNativeToForeignThunk (thunk);
1417
1417
}
1418
1418
1419
- if (auto thunkDecl = AFD->getDistributedThunk ()) {
1420
- if (!thunkDecl->isBodySkipped ()) {
1421
- auto thunk = SILDeclRef (thunkDecl).asDistributed ();
1422
- emitFunctionDefinition (SILDeclRef (thunkDecl).asDistributed (),
1423
- getFunction (thunk, ForDefinition));
1424
- }
1425
- }
1419
+ emitDistributedThunkForDecl (AFD);
1426
1420
1427
1421
if (AFD->isBackDeployed (M.getASTContext ())) {
1428
1422
// Emit the fallback function that will be used when the original function
Original file line number Diff line number Diff line change @@ -360,6 +360,11 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
360
360
// / Emits a thunk from an actor function to a potentially distributed call.
361
361
void emitDistributedThunk (SILDeclRef thunk);
362
362
363
+ // / Emits the distributed actor thunk for the decl if there is one associated
364
+ // / with it.
365
+ void emitDistributedThunkForDecl (
366
+ llvm::PointerUnion<AbstractFunctionDecl *, VarDecl *> varOrAFD);
367
+
363
368
// / Returns true if the given declaration must be referenced through a
364
369
// / back deployment thunk in a context with the given resilience expansion.
365
370
bool requiresBackDeploymentThunk (ValueDecl *decl,
Original file line number Diff line number Diff line change @@ -110,6 +110,23 @@ void SILGenModule::emitNativeToForeignThunk(SILDeclRef thunk) {
110
110
emitFunctionDefinition (thunk, getFunction (thunk, ForDefinition));
111
111
}
112
112
113
+ void SILGenModule::emitDistributedThunkForDecl (
114
+ llvm::PointerUnion<AbstractFunctionDecl *, VarDecl *> varOrAFD) {
115
+ FuncDecl *thunkDecl =
116
+ varOrAFD.is <AbstractFunctionDecl *>()
117
+ ? varOrAFD.get <AbstractFunctionDecl *>()->getDistributedThunk ()
118
+ : varOrAFD.get <VarDecl *>()->getDistributedThunk ();
119
+ if (!thunkDecl)
120
+ return ;
121
+
122
+ if (thunkDecl->isBodySkipped ())
123
+ return ;
124
+
125
+ auto thunk = SILDeclRef (thunkDecl).asDistributed ();
126
+ emitFunctionDefinition (SILDeclRef (thunkDecl).asDistributed (),
127
+ getFunction (thunk, ForDefinition));
128
+ }
129
+
113
130
void SILGenModule::emitDistributedThunk (SILDeclRef thunk) {
114
131
// Thunks are always emitted by need, so don't need delayed emission.
115
132
assert (thunk.isDistributedThunk () && " distributed thunks only" );
Original file line number Diff line number Diff line change @@ -1223,12 +1223,7 @@ class SILGenType : public TypeMemberVisitor<SILGenType> {
1223
1223
SGM.emitPropertyWrapperBackingInitializer (vd);
1224
1224
}
1225
1225
1226
- if (auto *thunk = vd->getDistributedThunk ()) {
1227
- auto thunkRef = SILDeclRef (thunk).asDistributed ();
1228
- SGM.emitFunctionDefinition (thunkRef,
1229
- SGM.getFunction (thunkRef, ForDefinition));
1230
- }
1231
-
1226
+ SGM.emitDistributedThunkForDecl (vd);
1232
1227
visitAbstractStorageDecl (vd);
1233
1228
}
1234
1229
@@ -1404,12 +1399,7 @@ class SILGenExtension : public TypeMemberVisitor<SILGenExtension> {
1404
1399
}
1405
1400
}
1406
1401
1407
- if (auto *thunk = vd->getDistributedThunk ()) {
1408
- auto thunkRef = SILDeclRef (thunk).asDistributed ();
1409
- SGM.emitFunctionDefinition (thunkRef,
1410
- SGM.getFunction (thunkRef, ForDefinition));
1411
- }
1412
-
1402
+ SGM.emitDistributedThunkForDecl (vd);
1413
1403
visitAbstractStorageDecl (vd);
1414
1404
}
1415
1405
Original file line number Diff line number Diff line change @@ -8,12 +8,25 @@ import Distributed
8
8
9
9
public distributed actor DA {
10
10
public typealias ActorSystem = LocalTestingDistributedActorSystem
11
+
12
+ // CHECK-NOT: s38distributed_thunk_skip_function_bodies2DAC9publicVarSiyYaKFTE
13
+ distributed var publicVar : Int {
14
+ let NEVER_TYPECHECK = 1
15
+ blackHole ( NEVER_TYPECHECK)
16
+ return 1
17
+ }
11
18
}
12
19
13
20
@inline ( never)
14
21
public func blackHole< T> ( _ t: T ) { }
15
22
16
23
extension DA {
24
+ // CHECK-NOT: s38distributed_thunk_skip_function_bodies2DAC20publicVarInExtensionSiyYaKFTE
25
+ distributed var publicVarInExtension : Int {
26
+ let NEVER_TYPECHECK = 1
27
+ blackHole ( NEVER_TYPECHECK)
28
+ return 1
29
+ }
17
30
18
31
// CHECK-NOT: s38distributed_thunk_skip_function_bodies2DAC10publicFuncyyYaKFTE
19
32
public distributed func publicFunc( ) {
You can’t perform that action at this time.
0 commit comments