Skip to content
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

IRGen: adjust protocol conformance references in PE/COFF #14710

Merged
merged 1 commit into from Mar 1, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/IRGen/GenDecl.cpp
Expand Up @@ -2252,6 +2252,17 @@ llvm::Function *IRGenModule::getAddrOfSILFunction(SILFunction *f,
static llvm::GlobalVariable *createGOTEquivalent(IRGenModule &IGM,
llvm::Constant *global,
StringRef globalName) {
if (IGM.Triple.getObjectFormat() == llvm::Triple::COFF) {
if (cast<llvm::GlobalValue>(global)->hasDLLImportStorageClass()) {
llvm::GlobalVariable *GV =
new llvm::GlobalVariable(IGM.Module, global->getType(),
/*Constant=*/true,
llvm::GlobalValue::ExternalLinkage,
nullptr, llvm::Twine("__imp_") + globalName);
GV->setExternallyInitialized(true);
return GV;
}
}

auto gotEquivalent = new llvm::GlobalVariable(IGM.Module,
global->getType(),
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/dllimport.swift
Expand Up @@ -52,7 +52,7 @@ public func g() {
// CHECK-OPT-DAG: declare dllimport %swift.refcounted* @swift_retain(%swift.refcounted* returned) local_unnamed_addr
// CHECK-OPT-DAG: @"$SBoWV" = external dllimport global i8*
// CHECK-OPT-DAG: @"$S9dllexport1cCN" = external dllimport global %swift.type
// CHECK-OPT-DAG: @"$S9dllexport1pMp" = external dllimport global %swift.protocol
// CHECK-OPT-DAG: @"__imp_$S9dllexport1pMp" = external externally_initialized constant %swift.protocol*
// CHECK-OPT-DAG: declare dllimport swiftcc i8* @"$S9dllexport2ciAA1cCvau"()
// CHECK-OPT-DAG: declare dllimport %swift.type* @"$S9dllexport1cCMa"()
// CHECK-OPT-DAG: declare dllimport void @swift_deallocClassInstance(%swift.refcounted*, i32, i32)
Expand Down