@@ -65,26 +65,31 @@ void SILGenModule::emitEntryPoint(SourceFile *SF, SILFunction *TopLevel) {
65
65
66
66
auto prologueLoc = RegularLocation::getModuleLocation ();
67
67
prologueLoc.markAsPrologue ();
68
- if (SF->isAsyncContext ()) {
69
- // emitAsyncMainThreadStart will create argc and argv.
70
- // Just set the main actor as the expected executor; we should
71
- // already be running on it.
72
- SILValue executor = TopLevelSGF.emitMainExecutor (prologueLoc);
73
- TopLevelSGF.ExpectedExecutor .set (TopLevelSGF.B .createOptionalSome (
74
- prologueLoc, executor, SILType::getOptionalType (executor->getType ())));
75
- } else {
76
- // Create the argc and argv arguments.
77
- auto entry = TopLevelSGF.B .getInsertionBB ();
78
- auto context = TopLevelSGF.getTypeExpansionContext ();
79
- auto paramTypeIter =
80
- TopLevelSGF.F .getConventions ().getParameterSILTypes (context).begin ();
81
-
82
- entry->createFunctionArgument (*paramTypeIter);
83
- entry->createFunctionArgument (*std::next (paramTypeIter));
84
- }
85
68
86
69
{
87
70
Scope S (TopLevelSGF.Cleanups , moduleCleanupLoc);
71
+
72
+ if (SF->isAsyncContext ()) {
73
+ // emitAsyncMainThreadStart will create argc and argv.
74
+ // Just set the main actor as the expected executor; we should
75
+ // already be running on it.
76
+ auto mainActorType =
77
+ getASTContext ().getMainActorType ()->getCanonicalType ();
78
+ TopLevelSGF.ExpectedExecutor .set (
79
+ TopLevelSGF.emitGlobalActorIsolation (prologueLoc, mainActorType)
80
+ .borrow (TopLevelSGF, prologueLoc)
81
+ .getValue ());
82
+ } else {
83
+ // Create the argc and argv arguments.
84
+ auto entry = TopLevelSGF.B .getInsertionBB ();
85
+ auto context = TopLevelSGF.getTypeExpansionContext ();
86
+ auto paramTypeIter =
87
+ TopLevelSGF.F .getConventions ().getParameterSILTypes (context).begin ();
88
+
89
+ entry->createFunctionArgument (*paramTypeIter);
90
+ entry->createFunctionArgument (*std::next (paramTypeIter));
91
+ }
92
+
88
93
SILGenTopLevel (TopLevelSGF).visitSourceFile (SF);
89
94
}
90
95
0 commit comments