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) {
14161416 emitNativeToForeignThunk (thunk);
14171417 }
14181418
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);
14261420
14271421 if (AFD->isBackDeployed (M.getASTContext ())) {
14281422 // 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> {
360360 // / Emits a thunk from an actor function to a potentially distributed call.
361361 void emitDistributedThunk (SILDeclRef thunk);
362362
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+
363368 // / Returns true if the given declaration must be referenced through a
364369 // / back deployment thunk in a context with the given resilience expansion.
365370 bool requiresBackDeploymentThunk (ValueDecl *decl,
Original file line number Diff line number Diff line change @@ -110,6 +110,23 @@ void SILGenModule::emitNativeToForeignThunk(SILDeclRef thunk) {
110110 emitFunctionDefinition (thunk, getFunction (thunk, ForDefinition));
111111}
112112
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+
113130void SILGenModule::emitDistributedThunk (SILDeclRef thunk) {
114131 // Thunks are always emitted by need, so don't need delayed emission.
115132 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> {
12231223 SGM.emitPropertyWrapperBackingInitializer (vd);
12241224 }
12251225
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);
12321227 visitAbstractStorageDecl (vd);
12331228 }
12341229
@@ -1404,12 +1399,7 @@ class SILGenExtension : public TypeMemberVisitor<SILGenExtension> {
14041399 }
14051400 }
14061401
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);
14131403 visitAbstractStorageDecl (vd);
14141404 }
14151405
Original file line number Diff line number Diff line change @@ -8,12 +8,25 @@ import Distributed
88
99public distributed actor DA {
1010 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+ }
1118}
1219
1320@inline ( never)
1421public func blackHole< T> ( _ t: T ) { }
1522
1623extension 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+ }
1730
1831 // CHECK-NOT: s38distributed_thunk_skip_function_bodies2DAC10publicFuncyyYaKFTE
1932 public distributed func publicFunc( ) {
You can’t perform that action at this time.
0 commit comments