From dec54ddec62982bf233d58040d7b80e79c029b4f Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 6 Mar 2025 10:54:30 -0800 Subject: [PATCH] IRGen: compute locality for type metadata accessor We previously did not properly compute the link info for type metadata accessor. This becomes a problem for metadata accessors which are canonically remote (e.g. the type metadata accessor for `NSError`). This fixes the incorrect DLLStorage that was being attributed to these functions. --- lib/IRGen/GenDecl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 1abf70142bf10..07678170fa4bd 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -2377,6 +2377,11 @@ LinkInfo LinkInfo::get(const UniversalLinkageInfo &linkInfo, // types to be referenced directly. if (const auto *MD = entity.getSILFunction()->getParentModule()) isKnownLocal = MD == swiftModule || MD->isStaticLibrary(); + } else if (entity.isTypeMetadataAccessFunction()) { + if (NominalTypeDecl *NTD = entity.getType()->getAnyNominal()) { + const ModuleDecl *MD = NTD->getDeclContext()->getParentModule(); + isKnownLocal = MD == swiftModule || MD->isStaticLibrary(); + } } bool weakImported = entity.isWeakImported(swiftModule);