@@ -418,6 +418,35 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
418
418
return false;
419
419
}
420
420
421
+ // Create our initial list of substitutions.
422
+ llvm::SmallVector<Substitution, 16> ApplySubs(InnerAI.subs_begin(),
423
+ InnerAI.subs_end());
424
+
425
+ // Then if we have a partial_apply, add any additional subsitutions that
426
+ // we may require to the end of the list.
427
+ if (PAI) {
428
+ copy(PAI->getSubstitutions(), std::back_inserter(ApplySubs));
429
+ }
430
+
431
+ SILOpenedArchetypesTracker OpenedArchetypesTracker(F);
432
+ F->getModule().registerDeleteNotificationHandler(
433
+ &OpenedArchetypesTracker);
434
+ // The callee only needs to know about opened archetypes used in
435
+ // the substitution list.
436
+ OpenedArchetypesTracker.registerUsedOpenedArchetypes(
437
+ InnerAI.getInstruction());
438
+ if (PAI) {
439
+ OpenedArchetypesTracker.registerUsedOpenedArchetypes(PAI);
440
+ }
441
+
442
+ SILInliner Inliner(*F, *CalleeFunction,
443
+ SILInliner::InlineKind::MandatoryInline, ApplySubs,
444
+ OpenedArchetypesTracker);
445
+ if (!Inliner.canInlineFunction(InnerAI)) {
446
+ I = InnerAI.getInstruction()->getIterator();
447
+ continue;
448
+ }
449
+
421
450
// Inline function at I, which also changes I to refer to the first
422
451
// instruction inlined in the case that it succeeds. We purposely
423
452
// process the inlined body after inlining, because the inlining may
@@ -456,31 +485,6 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
456
485
else
457
486
I = ApplyBlock->end();
458
487
459
- std::vector<Substitution> ApplySubs(InnerAI.getSubstitutions());
460
-
461
- if (PAI) {
462
- auto PAISubs = PAI->getSubstitutions();
463
- ApplySubs.insert(ApplySubs.end(), PAISubs.begin(), PAISubs.end());
464
- }
465
-
466
- SILOpenedArchetypesTracker OpenedArchetypesTracker(F);
467
- F->getModule().registerDeleteNotificationHandler(
468
- &OpenedArchetypesTracker);
469
- // The callee only needs to know about opened archetypes used in
470
- // the substitution list.
471
- OpenedArchetypesTracker.registerUsedOpenedArchetypes(InnerAI.getInstruction());
472
- if (PAI) {
473
- OpenedArchetypesTracker.registerUsedOpenedArchetypes(PAI);
474
- }
475
-
476
- SILInliner Inliner(*F, *CalleeFunction,
477
- SILInliner::InlineKind::MandatoryInline,
478
- ApplySubs, OpenedArchetypesTracker);
479
- if (!Inliner.canInlineFunction(InnerAI)) {
480
- I = InnerAI.getInstruction()->getIterator();
481
- continue;
482
- }
483
-
484
488
Inliner.inlineFunction(InnerAI, FullArgs);
485
489
486
490
// We were able to inline successfully. Remove the apply.
0 commit comments