[Embedded] Only emit global variables from another module if they are @used

This commit is contained in:
Doug Gregor
2026-05-19 16:04:32 -07:00
parent 047932a6d4
commit da170e7e8e
+3 -4
View File
@@ -1169,11 +1169,10 @@ static bool isLazilyEmittedFunction(SILFunction &f, SILModule &m) {
// Eagerly emit global variables that are externally visible.
static bool isLazilyEmittedGlobalVariable(SILGlobalVariable &v, SILModule &m) {
if (v.isPossiblyUsedExternally()) {
// Under the embedded linkage model, if it has a non-unique definition,
// treat it lazily.
if (v.hasNonUniqueDefinition() && !v.markedAsUsed()) {
// Globals that come from a different module will be lazily emitted unless
// explicitly marked @used.
if (v.getParentModule() != m.getSwiftModule() && !v.markedAsUsed())
return true;
}
return false;
}