Skip to content

Commit fe96897

Browse files
committed
We were accidentally giving value witnesses default visibility,
which doesn't play well with others. Swift SVN r1996
1 parent c9fdb3b commit fe96897

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,18 @@ LinkInfo LinkInfo::get(IRGenModule &IGM, const LinkEntity &entity) {
120120

121121
llvm::raw_svector_ostream nameStream(result.Name);
122122
entity.mangle(nameStream);
123-
124-
// TODO, obviously.
125-
result.Linkage = llvm::GlobalValue::ExternalLinkage;
126-
result.Visibility = llvm::GlobalValue::DefaultVisibility;
123+
124+
// The linkage for a value witness is linkonce_odr.
125+
if (entity.isValueWitness()) {
126+
result.Linkage = llvm::GlobalValue::LinkOnceODRLinkage;
127+
result.Visibility = llvm::GlobalValue::HiddenVisibility;
128+
129+
// Give everything else external linkage.
130+
} else {
131+
result.Linkage = llvm::GlobalValue::ExternalLinkage;
132+
result.Visibility = llvm::GlobalValue::DefaultVisibility;
133+
}
134+
127135
return result;
128136
}
129137

lib/IRGen/Linking.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class LinkEntity {
153153
return LINKENTITY_GET_FIELD(Data, UncurryLevel);
154154
}
155155

156+
bool isValueWitness() const { return getKind() == Kind::ValueWitness; }
156157
Type getType() const {
157158
assert(isTypeKind(getKind()));
158159
return reinterpret_cast<TypeBase*>(Pointer);

0 commit comments

Comments
 (0)