Skip to content

Commit 02dfb50

Browse files
committed
IRGen: create new External{Im,Ex}port named linkages
Create two new semantic names: `ExternalImport` and `ExternalExport`. These are for symbols which are either imported from an external module or exported for consumption by external modules.
1 parent 9546cc2 commit 02dfb50

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

include/swift/IRGen/Linking.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,9 @@ struct IRLinkage {
10451045
static const IRLinkage InternalLinkOnceODR;
10461046
static const IRLinkage InternalWeakODR;
10471047
static const IRLinkage Internal;
1048+
1049+
static const IRLinkage ExternalImport;
1050+
static const IRLinkage ExternalExport;
10481051
};
10491052

10501053
class ApplyIRLinkage {

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,7 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) {
960960
encodeForceLoadSymbolName(buf, linkLib.getName());
961961
auto ForceImportThunk =
962962
Module.getOrInsertFunction(buf, llvm::FunctionType::get(VoidTy, false));
963-
ApplyIRLinkage({llvm::GlobalValue::ExternalLinkage,
964-
llvm::GlobalValue::DefaultVisibility,
965-
llvm::GlobalValue::DLLImportStorageClass})
963+
ApplyIRLinkage(IRLinkage::ExternalImport)
966964
.to(cast<llvm::GlobalValue>(ForceImportThunk));
967965

968966
buf += "_$";
@@ -1084,10 +1082,7 @@ void IRGenModule::emitAutolinkInfo() {
10841082
llvm::Function::Create(llvm::FunctionType::get(VoidTy, false),
10851083
llvm::GlobalValue::ExternalLinkage, buf,
10861084
&Module);
1087-
ApplyIRLinkage({llvm::GlobalValue::ExternalLinkage,
1088-
llvm::GlobalValue::DefaultVisibility,
1089-
llvm::GlobalValue::DLLExportStorageClass})
1090-
.to(ForceImportThunk);
1085+
ApplyIRLinkage(IRLinkage::ExternalExport).to(ForceImportThunk);
10911086

10921087
auto BB = llvm::BasicBlock::Create(getLLVMContext(), "", ForceImportThunk);
10931088
llvm::IRBuilder<> IRB(BB);

lib/IRGen/Linking.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ const IRLinkage IRLinkage::Internal = {
4949
llvm::GlobalValue::DefaultStorageClass,
5050
};
5151

52+
const IRLinkage IRLinkage::ExternalImport = {
53+
llvm::GlobalValue::ExternalLinkage,
54+
llvm::GlobalValue::DefaultVisibility,
55+
llvm::GlobalValue::DLLImportStorageClass,
56+
};
57+
58+
const IRLinkage IRLinkage::ExternalExport = {
59+
llvm::GlobalValue::ExternalLinkage,
60+
llvm::GlobalValue::DefaultVisibility,
61+
llvm::GlobalValue::DLLExportStorageClass,
62+
};
63+
5264
bool swift::irgen::useDllStorage(const llvm::Triple &triple) {
5365
return triple.isOSBinFormatCOFF() && !triple.isOSCygMing();
5466
}

0 commit comments

Comments
 (0)