@@ -152,8 +152,11 @@ SILDeclRef::SILDeclRef(ValueDecl *vd, SILDeclRef::Kind kind,
152152 " can only create ivar initializer/destroyer SILDeclRef for class" );
153153 naturalUncurryLevel = 1 ;
154154 } else if (auto *var = dyn_cast<VarDecl>(vd)) {
155- assert ((kind == Kind::GlobalAccessor || kind == Kind::GlobalGetter) &&
156- " can only create GlobalAccessor or GlobalGetter SILDeclRef for var" );
155+ assert ((kind == Kind::GlobalAccessor ||
156+ kind == Kind::GlobalGetter ||
157+ kind == Kind::StoredPropertyInitializer) &&
158+ " can only create GlobalAccessor, GlobalGetter or "
159+ " StoredPropertyInitializer SILDeclRef for var" );
157160
158161 naturalUncurryLevel = 0 ;
159162 assert (!var->getDeclContext ()->isLocalContext () &&
@@ -316,9 +319,14 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
316319
317320 // Enum constructors are essentially the same as thunks, they are
318321 // emitted by need and have shared linkage.
319- if (kind == Kind::EnumElement )
322+ if (isEnumElement () )
320323 return SILLinkage::Shared;
321324
325+ // Stored property initializers have hidden linkage, since they are
326+ // not meant to be used from outside of their module.
327+ if (isStoredPropertyInitializer ())
328+ return SILLinkage::Hidden;
329+
322330 // Declarations imported from Clang modules have shared linkage.
323331 const SILLinkage ClangLinkage = SILLinkage::Shared;
324332
@@ -353,6 +361,9 @@ bool SILDeclRef::isTransparent() const {
353361 if (isEnumElement ())
354362 return true ;
355363
364+ if (isStoredPropertyInitializer ())
365+ return true ;
366+
356367 if (hasAutoClosureExpr ())
357368 return true ;
358369
@@ -576,12 +587,18 @@ static std::string mangleConstant(SILDeclRef c, StringRef prefix) {
576587 mangler.mangleGlobalGetterEntity (c.getDecl ());
577588 return mangler.finalize ();
578589
579- // entity ::= context 'e' index // default arg generator
590+ // entity ::= context 'e' index // default arg generator
580591 case SILDeclRef::Kind::DefaultArgGenerator:
581592 mangler.append (introducer);
582593 mangler.mangleDefaultArgumentEntity (cast<AbstractFunctionDecl>(c.getDecl ()),
583594 c.defaultArgIndex );
584595 return mangler.finalize ();
596+
597+ // entity ::= 'I' declaration 'i' // stored property initializer
598+ case SILDeclRef::Kind::StoredPropertyInitializer:
599+ mangler.append (introducer);
600+ mangler.mangleInitializerEntity (cast<VarDecl>(c.getDecl ()));
601+ return mangler.finalize ();
585602 }
586603
587604 llvm_unreachable (" bad entity kind!" );
0 commit comments