diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index d3a8bd179f8..d7128d2c91b 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -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; }