Skip to content
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
3 changes: 3 additions & 0 deletions include/swift/IRGen/Linking.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,9 @@ struct IRLinkage {
llvm::GlobalValue::LinkageTypes Linkage;
llvm::GlobalValue::VisibilityTypes Visibility;
llvm::GlobalValue::DLLStorageClassTypes DLLStorage;

static const IRLinkage InternalLinkOnceODR;
static const IRLinkage Internal;
};

class ApplyIRLinkage {
Expand Down
7 changes: 3 additions & 4 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3914,6 +3914,8 @@ IRGenModule::getAddrOfWitnessTableLazyAccessFunction(
Signature signature(fnType, llvm::AttributeList(), DefaultCC);
LinkInfo link = LinkInfo::get(*this, entity, forDefinition);
entry = createFunction(*this, link, signature);
ApplyIRLinkage({link.getLinkage(), link.getVisibility(), link.getDLLStorage()})
.to(entry);
return entry;
}

Expand Down Expand Up @@ -4026,10 +4028,7 @@ static llvm::Function *shouldDefineHelper(IRGenModule &IGM,
if (!def) return nullptr;
if (!def->empty()) return nullptr;

ApplyIRLinkage({llvm::GlobalValue::LinkOnceODRLinkage,
llvm::GlobalValue::HiddenVisibility,
llvm::GlobalValue::DefaultStorageClass})
.to(def);
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR).to(def);
def->setDoesNotThrow();
def->setCallingConv(IGM.DefaultCC);
if (setIsNoInline)
Expand Down
5 changes: 1 addition & 4 deletions lib/IRGen/GenEnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,10 +1473,7 @@ namespace {
auto func =
llvm::Function::Create(consumeTy, llvm::GlobalValue::LinkOnceODRLinkage,
llvm::StringRef(name), IGM.getModule());
ApplyIRLinkage({llvm::GlobalValue::LinkOnceODRLinkage,
llvm::GlobalValue::HiddenVisibility,
llvm::GlobalValue::DefaultStorageClass})
.to(func);
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR).to(func);
func->setAttributes(IGM.constructInitialAttributes());
func->setDoesNotThrow();
func->setCallingConv(IGM.DefaultCC);
Expand Down
5 changes: 1 addition & 4 deletions lib/IRGen/GenObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,10 +931,7 @@ static llvm::Constant *findSwiftAsObjCThunk(IRGenModule &IGM, SILDeclRef ref,
SILFn = IGM.getSILModule().lookUpFunction(ref);
assert(SILFn && "no IR function for swift-as-objc thunk");
auto fn = IGM.getAddrOfSILFunction(SILFn, NotForDefinition);
ApplyIRLinkage({llvm::GlobalValue::InternalLinkage,
llvm::GlobalValue::DefaultVisibility,
llvm::GlobalValue::DefaultStorageClass})
.to(fn);
ApplyIRLinkage(IRLinkage::Internal).to(fn);
fn->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

return llvm::ConstantExpr::getBitCast(fn, IGM.Int8PtrTy);
Expand Down
5 changes: 1 addition & 4 deletions lib/IRGen/GenReflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,10 +980,7 @@ void IRGenModule::emitReflectionMetadataVersion() {
llvm::GlobalValue::LinkOnceODRLinkage,
Init,
"__swift_reflection_version");
ApplyIRLinkage({llvm::GlobalValue::LinkOnceODRLinkage,
llvm::GlobalValue::HiddenVisibility,
llvm::GlobalValue::DefaultStorageClass})
.to(Version);
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR).to(Version);
addUsedGlobal(Version);
}

Expand Down
12 changes: 12 additions & 0 deletions lib/IRGen/Linking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ using namespace swift;
using namespace irgen;
using namespace Mangle;

const IRLinkage IRLinkage::InternalLinkOnceODR = {
llvm::GlobalValue::LinkOnceODRLinkage,
llvm::GlobalValue::HiddenVisibility,
llvm::GlobalValue::DefaultStorageClass,
};

const IRLinkage IRLinkage::Internal = {
llvm::GlobalValue::InternalLinkage,
llvm::GlobalValue::DefaultVisibility,
llvm::GlobalValue::DefaultStorageClass,
};

bool swift::irgen::useDllStorage(const llvm::Triple &triple) {
return triple.isOSBinFormatCOFF() && !triple.isOSCygMing();
}
Expand Down
5 changes: 1 addition & 4 deletions lib/IRGen/MetadataRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,7 @@ llvm::Constant *IRGenModule::getAddrOfStringForTypeRef(
llvm::GlobalValue::LinkOnceODRLinkage,
nullptr,
symbolName);
ApplyIRLinkage({llvm::GlobalValue::LinkOnceODRLinkage,
llvm::GlobalValue::HiddenVisibility,
llvm::GlobalValue::DefaultStorageClass})
.to(var);
ApplyIRLinkage(IRLinkage::InternalLinkOnceODR).to(var);
var->setAlignment(2);
setTrueConstGlobal(var);
var->setSection(getReflectionTypeRefSectionName());
Expand Down