Skip to content

Commit f0c0bd8

Browse files
committed
Revert "Merge pull request #7401 from swiftix/wip-generics-inlining-flag-4"
This reverts commit a380855, reversing changes made to 6633214. We're seeing a handful of issues from turning on inlining of generics, so I'm reverting to unblock the bots.
1 parent 1a0a32d commit f0c0bd8

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

lib/SIL/SILModule.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -499,14 +499,6 @@ bool SILModule::linkFunction(StringRef Name, SILModule::LinkingMode Mode) {
499499
return SILLinkerVisitor(*this, getSILLoader(), Mode).processFunction(Name);
500500
}
501501

502-
bool SILModule::hasFunction(StringRef Name) {
503-
if (lookUpFunction(Name))
504-
return true;
505-
SILLinkerVisitor Visitor(*this, getSILLoader(),
506-
SILModule::LinkingMode::LinkNormal);
507-
return Visitor.hasFunction(Name);
508-
}
509-
510502
/// Check if a given SIL linkage matches the required linkage.
511503
/// If the required linkage is Private, then anything matches it.
512504
static bool isMatchingLinkage(SILLinkage ActualLinkage,
@@ -516,15 +508,19 @@ static bool isMatchingLinkage(SILLinkage ActualLinkage,
516508
return ActualLinkage == Linkage;
517509
}
518510

511+
bool SILModule::hasFunction(StringRef Name) {
512+
if (lookUpFunction(Name))
513+
return true;
514+
SILLinkerVisitor Visitor(*this, getSILLoader(),
515+
SILModule::LinkingMode::LinkNormal);
516+
return Visitor.hasFunction(Name);
517+
}
518+
519519
SILFunction *SILModule::findFunction(StringRef Name,
520520
Optional<SILLinkage> Linkage) {
521-
assert(Linkage);
522-
auto RequiredLinkage = *Linkage;
523-
assert((RequiredLinkage == SILLinkage::Public ||
524-
RequiredLinkage == SILLinkage::PublicExternal) &&
525-
"Only a lookup of public functions is supported currently");
526521

527522
SILFunction *F = nullptr;
523+
SILLinkage RequiredLinkage = Linkage ? *Linkage : SILLinkage::Private;
528524

529525
// First, check if there is a function with a required name in the
530526
// current module.
@@ -569,20 +565,27 @@ SILFunction *SILModule::findFunction(StringRef Name,
569565
}
570566
}
571567

572-
// If an external public function representing a pre-specialization
573-
// exists already and it is a non-optimizing compilation,
574-
// simply convert it into an external declaration,
568+
// If a function exists already and it is a non-optimizing
569+
// compilation, simply convert it into an external declaration,
575570
// so that a compiled version from the shared library is used.
576-
// It is important to remove its body here, because it may
577-
// contain references to non-public functions.
578571
if (F->isDefinition() &&
579572
F->getModule().getOptions().Optimization <
580573
SILOptions::SILOptMode::Optimize) {
581574
F->convertToDeclaration();
582575
}
583-
if (F->isExternalDeclaration())
576+
if (F->isExternalDeclaration()) {
584577
F->setFragile(IsFragile_t::IsNotFragile);
585-
F->setLinkage(RequiredLinkage);
578+
if (isAvailableExternally(F->getLinkage()) &&
579+
!hasPublicVisibility(F->getLinkage()) && !Linkage) {
580+
// We were just asked if a given function exists anywhere.
581+
// It is not going to be used by the current module.
582+
// Since external non-public function declarations should not
583+
// exist, strip the "external" part from the linkage.
584+
F->setLinkage(stripExternalFromLinkage(F->getLinkage()));
585+
}
586+
}
587+
if (Linkage)
588+
F->setLinkage(RequiredLinkage);
586589
return F;
587590
}
588591

0 commit comments

Comments
 (0)