IRGen: apply IR linkage to trivial property descriptors

This ensures that the trivial property descriptors is externally
accessible on targets like Windows which does not export symbols by
default.  Thanks to Joe Groff for the pointer about the global aliases
for trivial property descriptors!
This commit is contained in:
Saleem Abdulrasool
2019-01-08 13:37:39 -08:00
parent be33d1728c
commit fc86d09f59
2 changed files with 18 additions and 4 deletions

View File

@@ -1269,14 +1269,18 @@ void IRGenModule::emitSILProperty(SILProperty *prop) {
var->setConstant(true);
var->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
var->setAlignment(4);
TheTrivialPropertyDescriptor = var;
} else {
auto entity = LinkEntity::forPropertyDescriptor(prop->getDecl());
auto linkInfo = LinkInfo::get(*this, entity, ForDefinition);
llvm::GlobalAlias::create(linkInfo.getLinkage(),
linkInfo.getName(),
TheTrivialPropertyDescriptor);
auto *GA = llvm::GlobalAlias::create(linkInfo.getLinkage(),
linkInfo.getName(),
TheTrivialPropertyDescriptor);
ApplyIRLinkage({linkInfo.getLinkage(),
linkInfo.getVisibility(),
llvm::GlobalValue::DLLExportStorageClass})
.to(GA);
}
return;
}