@@ -54,6 +54,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
54
54
SubstitutionMap Subs;
55
55
SmallVector<SILValue, 8 > Args;
56
56
SubstitutionMap RecursiveSubs;
57
+ ApplyOptions ApplyOpts;
57
58
58
59
public:
59
60
ApplySiteCloningHelper (ApplySite AI, TypeSubstCloner &Cloner)
@@ -67,6 +68,14 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
67
68
// Remap substitutions.
68
69
Subs = Cloner.getOpSubstitutionMap (AI.getSubstitutionMap ());
69
70
71
+ // If we're inlining a [noasync] function, make sure any calls inside it
72
+ // are marked as [noasync] as appropriate.
73
+ ApplyOpts = AI.getApplyOptions ();
74
+ if (!Builder.getFunction ().isAsync () &&
75
+ SubstCalleeSILType.castTo <SILFunctionType>()->isAsync ()) {
76
+ ApplyOpts |= ApplyFlags::DoesNotAwait;
77
+ }
78
+
70
79
if (!Cloner.Inlining ) {
71
80
FunctionRefInst *FRI = dyn_cast<FunctionRefInst>(AI.getCallee ());
72
81
if (FRI && FRI->getReferencedFunction () == AI.getFunction () &&
@@ -123,6 +132,10 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
123
132
SubstitutionMap getSubstitutions () const {
124
133
return Subs;
125
134
}
135
+
136
+ ApplyOptions getApplyOptions () const {
137
+ return ApplyOpts;
138
+ }
126
139
};
127
140
128
141
public:
@@ -214,7 +227,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
214
227
getBuilder ().createApply (getOpLocation (Inst->getLoc ()),
215
228
Helper.getCallee (), Helper.getSubstitutions (),
216
229
Helper.getArguments (),
217
- Inst-> getApplyOptions (),
230
+ Helper. getApplyOptions (),
218
231
GenericSpecializationInformation::create (
219
232
Inst, getBuilder ()));
220
233
// Specialization can return noreturn applies that were not identified as
@@ -234,7 +247,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
234
247
Helper.getSubstitutions (), Helper.getArguments (),
235
248
getOpBasicBlock (Inst->getNormalBB ()),
236
249
getOpBasicBlock (Inst->getErrorBB ()),
237
- Inst-> getApplyOptions (),
250
+ Helper. getApplyOptions (),
238
251
GenericSpecializationInformation::create (
239
252
Inst, getBuilder ()));
240
253
recordClonedInstruction (Inst, N);
0 commit comments