Skip to content

Commit

Permalink
Merge pull request #14710 from compnerd/got-coff
Browse files Browse the repository at this point in the history
  • Loading branch information
swift-ci committed Mar 1, 2018
2 parents 17d11d7 + ae5cfae commit 72d7dd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 72d7dd2

Please sign in to comment.