IRGen/SIL: Fix IR linkage computation for inlined function references from modules imported @_weakLinked.

Include the parent `ModuleDecl` when serializing a `SILFunction` so that it is available on deserialized functions even though the full `DeclContext` is not present. With the parent module always available we can reliably compute whether the `SILFunction` comes from a module that was imported `@_weakLinked`.

Serialize the `DeclContext` member of `SILFunction` so that it can be used to look up the module that a function belongs to in order to compute weak import status.

Resolves rdar://98521248
This commit is contained in:
Allan Shortlidge
2022-08-12 16:56:05 -07:00
parent df66f2777e
commit 40eb1422bb
17 changed files with 112 additions and 70 deletions

View File

@@ -312,14 +312,7 @@ SILFunction *SILFunctionBuilder::getOrCreateFunction(
F->setClangNodeOwner(decl);
F->setAvailabilityForLinkage(decl->getAvailabilityForLinkage());
if (decl->isAlwaysWeakImported()) {
F->setIsWeakImported(IsWeakImported_t::IsAlwaysWeakImported);
} else if (decl->isWeakImported(mod.getSwiftModule())) {
F->setIsWeakImported(IsWeakImported_t::IsWeakImportedByModule);
} else {
F->setIsWeakImported(IsWeakImported_t::IsNotWeakImported);
}
F->setIsAlwaysWeakImported(decl->isAlwaysWeakImported());
if (auto *accessor = dyn_cast<AccessorDecl>(decl)) {
auto *storage = accessor->getStorage();