Skip to content

IRGen: apply IR linkage to trivial property descriptors #21720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/IRGen/GenKeyPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions test/IRGen/trivial-property-descriptors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %swift -target x86_64-unknown-windows-msvc -parse-stdlib -module-name Swift -enable-resilience -S -emit-ir -o - %s | %FileCheck %s

public struct S {}
extension S {
public var i: () { return () }
public var j: () { return () }
}

// CHECK: @"$ss1SV1jytvpMV" = dllexport alias { i32 }, { i32 }* @"$ss1SV1iytvpMV"