Skip to content

Commit 12dfcc4

Browse files
committed
Inliner: allow the inliner generate partial_apply with an open existential in the substitution list.
There was an old check in the inliner which prevented this, because IRGen didn't support it. Now it seems that IRGen can handle "partial_apply <@opened...>", so we can remove that check in the inliner.
1 parent 5a8e3ea commit 12dfcc4

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

lib/SILOptimizer/Utils/PerformanceInlinerUtils.cpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -556,49 +556,6 @@ static bool calleeIsSelfRecursive(SILFunction *Callee) {
556556
return false;
557557
}
558558

559-
// Returns true if the callee contains a partial apply instruction,
560-
// whose substitutions list would contain opened existentials after
561-
// inlining.
562-
static bool calleeHasPartialApplyWithOpenedExistentials(FullApplySite AI) {
563-
if (!AI.hasSubstitutions())
564-
return false;
565-
566-
SILFunction *Callee = AI.getReferencedFunctionOrNull();
567-
assert(Callee && "Trying to optimize a dynamic function?!");
568-
569-
auto SubsMap = AI.getSubstitutionMap();
570-
571-
// Bail if there are no open existentials in the list of substitutions.
572-
bool HasNoOpenedExistentials = true;
573-
for (auto Replacement : SubsMap.getReplacementTypes()) {
574-
if (Replacement->hasOpenedExistential()) {
575-
HasNoOpenedExistentials = false;
576-
break;
577-
}
578-
}
579-
580-
if (HasNoOpenedExistentials)
581-
return false;
582-
583-
for (auto &BB : *Callee) {
584-
for (auto &I : BB) {
585-
if (auto PAI = dyn_cast<PartialApplyInst>(&I)) {
586-
if (!PAI->hasSubstitutions())
587-
continue;
588-
589-
// Check if any of substitutions would contain open existentials
590-
// after inlining.
591-
auto PAISubMap = PAI->getSubstitutionMap();
592-
PAISubMap = PAISubMap.subst(SubsMap);
593-
if (PAISubMap.hasOpenedExistential())
594-
return true;
595-
}
596-
}
597-
}
598-
599-
return false;
600-
}
601-
602559
// Returns true if a given apply site should be skipped during the
603560
// early inlining pass.
604561
//
@@ -781,12 +738,6 @@ SILFunction *swift::getEligibleFunction(FullApplySite AI,
781738
return nullptr;
782739
}
783740

784-
// IRGen cannot handle partial_applies containing opened_existentials
785-
// in its substitutions list.
786-
if (calleeHasPartialApplyWithOpenedExistentials(AI)) {
787-
return nullptr;
788-
}
789-
790741
return Callee;
791742
}
792743

0 commit comments

Comments
 (0)