Skip to content

Commit b246d09

Browse files
committed
SILOptimizer: Don't inline functions that directly reference the metatype of $Self
Formerly SILGen would never emit this sequence. In fact in most places we lower away dynamic Self, replacing it with the concrete Self type instead. However, with an upcoming change, I'm using 'metatype $Self' as a handy way to grab IRGenSILFunction::LocalSelfMetadata, since that's what it already does. Note that the tests for this are in the next patch.
1 parent cbf1ab2 commit b246d09

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/SILOptimizer/Utils/Local.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,14 @@ bool swift::hasDynamicSelfTypes(ArrayRef<Substitution> Subs) {
357357

358358
bool swift::computeMayBindDynamicSelf(SILFunction *F) {
359359
for (auto &BB : *F)
360-
for (auto &I : BB)
361-
if (auto Apply = FullApplySite::isa(&I))
362-
if (hasDynamicSelfTypes(Apply.getSubstitutions()))
360+
for (auto &I : BB) {
361+
if (auto AI = FullApplySite::isa(&I))
362+
if (hasDynamicSelfTypes(AI.getSubstitutions()))
363363
return true;
364+
if (auto MI = dyn_cast<MetatypeInst>(&I))
365+
if (MI->getType().getSwiftRValueType()->hasDynamicSelfType())
366+
return true;
367+
}
364368
return false;
365369
}
366370

0 commit comments

Comments
 (0)