Skip to content

Commit 707b416

Browse files
author
ematejska
authored
Merge pull request #11136 from huonw/symbol-list-10-4.0
[4.0] TBD including all files from a full build.
2 parents 72bc593 + e1e48ab commit 707b416

File tree

12 files changed

+92
-87
lines changed

12 files changed

+92
-87
lines changed

lib/SILGen/SILGenMaterializeForSet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,12 @@ SILFunction *MaterializeForSetEmitter::createCallback(SILFunction &F,
682682
// the actual materializeForSet function), and so we only need to make sure we
683683
// don't break things in cases when there may be multiple definitions.
684684
auto callbackLinkage =
685-
hasSharedVisibility(Linkage) ? SILLinkage::Shared : SILLinkage::Private;
685+
F.isSerialized() ? SILLinkage::Shared : SILLinkage::Private;
686686

687687
auto callback = SGM.M.createFunction(
688688
callbackLinkage, CallbackName, callbackType, genericEnv,
689-
SILLocation(Witness), IsBare, F.isTransparent(), F.isSerialized(),
690-
IsNotThunk, SubclassScope::NotApplicable,
689+
SILLocation(Witness), IsBare, F.isTransparent(), F.isSerialized(), IsNotThunk,
690+
SubclassScope::NotApplicable,
691691
/*inlineStrategy=*/InlineDefault,
692692
/*EK=*/EffectsKind::Unspecified,
693693
/*InsertBefore=*/&F);

lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -637,18 +637,7 @@ void FunctionSignatureTransform::createFunctionSignatureOptimizedFunction() {
637637
// Create the optimized function !
638638
SILModule &M = F->getModule();
639639
std::string Name = createOptimizedSILFunctionName();
640-
641-
// Any function that can be seen in other compilation units within this module
642-
// (either because the function is from another module, or because it public
643-
// or internal) needs to be considered shared, because those compilation units
644-
// may choose to do exactly the same specialization. However, specializations
645-
// of serialized functions are serialized too, and so behave more like the
646-
// original.
647-
SILLinkage linkage = F->getLinkage();
648-
auto localVisibleInOtherObjects =
649-
!hasPrivateVisibility(linkage) && !F->isSerialized();
650-
if (isAvailableExternally(linkage) || localVisibleInOtherObjects)
651-
linkage = SILLinkage::Shared;
640+
SILLinkage linkage = getSpecializedLinkage(F, F->getLinkage());
652641

653642
DEBUG(llvm::dbgs() << " -> create specialized function " << Name << "\n");
654643

lib/TBDGen/TBDGen.cpp

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
4444
bool FileHasEntryPoint;
4545
bool SILSerializeWitnessTables;
4646

47+
bool InsideAbstractStorageDecl = false;
48+
4749
void addSymbol(StringRef name) {
4850
auto isNewValue = Symbols.insert(name).second;
4951
(void)isNewValue;
5052
assert(isNewValue && "already inserted");
5153
}
5254

53-
void addSymbol(SILDeclRef declRef, bool checkSILOnly = true);
55+
void addSymbol(SILDeclRef declRef);
5456

5557
void addSymbol(LinkEntity entity) {
5658
auto linkage =
@@ -85,8 +87,8 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
8587
addMembers(ED->getMembers());
8688
else if (auto NTD = dyn_cast<NominalTypeDecl>(D))
8789
addMembers(NTD->getMembers());
88-
else if (auto VD = dyn_cast<VarDecl>(D))
89-
VD->getAllAccessorFunctions(members);
90+
else if (auto ASD = dyn_cast<AbstractStorageDecl>(D))
91+
ASD->getAllAccessorFunctions(members);
9092

9193
for (auto member : members) {
9294
ASTVisitor::visit(member);
@@ -103,20 +105,18 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
103105
// any information here is encoded elsewhere
104106
}
105107

106-
void visitSubscriptDecl(SubscriptDecl *SD) {
107-
// Any getters and setters etc. exist as independent FuncDecls in the AST,
108-
// so get processed elsewhere; subscripts don't have any symbols other than
109-
// these.
110-
}
111-
112108
void visitNominalTypeDecl(NominalTypeDecl *NTD);
113109

114110
void visitClassDecl(ClassDecl *CD);
115111

112+
void visitConstructorDecl(ConstructorDecl *CD);
113+
116114
void visitExtensionDecl(ExtensionDecl *ED);
117115

118116
void visitProtocolDecl(ProtocolDecl *PD);
119117

118+
void visitAbstractStorageDecl(AbstractStorageDecl *ASD);
119+
120120
void visitVarDecl(VarDecl *VD);
121121

122122
void visitDecl(Decl *D) { visitMembers(D); }
@@ -138,13 +138,13 @@ void TBDGenVisitor::visitPatternBindingDecl(PatternBindingDecl *PBD) {
138138
auto declRef =
139139
SILDeclRef(var, SILDeclRef::Kind::StoredPropertyInitializer);
140140
// Stored property initializers for public properties are currently
141-
// public, even when the initializer is marked as SIL only (transparent).
142-
addSymbol(declRef, /*checkSILOnly=*/false);
141+
// public.
142+
addSymbol(declRef);
143143
}
144144
}
145145
}
146146

147-
void TBDGenVisitor::addSymbol(SILDeclRef declRef, bool checkSILOnly) {
147+
void TBDGenVisitor::addSymbol(SILDeclRef declRef) {
148148
bool isPrivate = !hasPublicVisibility(declRef.getLinkage(ForDefinition));
149149
// Even private methods of open classes (specifically, private methods that
150150
// are in the vtable) have public symbols, because external subclasses
@@ -155,7 +155,6 @@ void TBDGenVisitor::addSymbol(SILDeclRef declRef, bool checkSILOnly) {
155155
// unconditionally, even if they're theoretically SIL only.
156156
if (isPrivate) {
157157
isPrivate = false;
158-
checkSILOnly = false;
159158
}
160159
break;
161160
case SubclassScope::Internal:
@@ -165,10 +164,9 @@ void TBDGenVisitor::addSymbol(SILDeclRef declRef, bool checkSILOnly) {
165164
if (isPrivate)
166165
return;
167166

168-
// (Most) transparent things don't exist, even if they're public.
169-
// FIXME: isTransparent should really be "is SIL only".
170-
if (checkSILOnly && declRef.isTransparent())
171-
return;
167+
// FIXME: this includes too many symbols. There are some that are considered
168+
// SIL-only, but it isn't obvious how to determine this (e.g. it seems that
169+
// many, but not all, transparent functions result in object-file symbols)
172170

173171
addSymbol(declRef.mangle());
174172
}
@@ -256,6 +254,14 @@ void TBDGenVisitor::visitValueDecl(ValueDecl *VD) {
256254
}
257255

258256
void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
257+
if (auto FD = dyn_cast<FuncDecl>(AFD)) {
258+
// Accessors also appear nested inside the storage decl, which we treat as
259+
// the canonical location, so skip if we've got an accessor that isn't
260+
// inside the var decl.
261+
if (FD->getAccessorStorageDecl() && !InsideAbstractStorageDecl)
262+
return;
263+
}
264+
259265
// Default arguments (of public functions) are public symbols, as the default
260266
// values are computed at the call site.
261267
auto index = 0;
@@ -275,25 +281,27 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
275281
visitValueDecl(AFD);
276282
}
277283

284+
void TBDGenVisitor::visitAbstractStorageDecl(AbstractStorageDecl *ASD) {
285+
assert(!InsideAbstractStorageDecl &&
286+
"unexpected nesting of abstract storage decls");
287+
InsideAbstractStorageDecl = true;
288+
visitMembers(ASD);
289+
InsideAbstractStorageDecl = false;
290+
}
278291
void TBDGenVisitor::visitVarDecl(VarDecl *VD) {
279-
if (isPrivateDecl(VD))
280-
return;
281-
282292
// statically/globally stored variables have some special handling.
283293
if (VD->hasStorage() && isGlobalOrStaticVar(VD)) {
284294
// The actual variable has a symbol.
285295
Mangle::ASTMangler mangler;
286296
addSymbol(mangler.mangleEntity(VD, false));
287297

288-
// Variables in the main file don't get accessors, despite otherwise looking
289-
// like globals.
290-
if (!FileHasEntryPoint)
298+
// Top-level variables (*not* statics) in the main file don't get accessors,
299+
// despite otherwise looking like globals.
300+
if (!FileHasEntryPoint || VD->isStatic())
291301
addSymbol(SILDeclRef(VD, SILDeclRef::Kind::GlobalAccessor));
292-
293-
// In this case, the members of the VarDecl don't also appear as top-level
294-
// decls, so we need to explicitly walk them.
295-
visitMembers(VD);
296302
}
303+
304+
visitAbstractStorageDecl(VD);
297305
}
298306

299307
void TBDGenVisitor::visitNominalTypeDecl(NominalTypeDecl *NTD) {
@@ -344,8 +352,7 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
344352
continue;
345353

346354
auto var = dyn_cast<VarDecl>(value);
347-
auto hasFieldOffset =
348-
!isGeneric && var && var->hasStorage() && !var->isStatic();
355+
auto hasFieldOffset = var && var->hasStorage() && !var->isStatic();
349356
if (hasFieldOffset) {
350357
// FIXME: a field only has one sort of offset, but it is moderately
351358
// non-trivial to compute which one. Including both is less painful than
@@ -354,10 +361,8 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
354361
addSymbol(LinkEntity::forFieldOffset(var, /*isIndirect=*/true));
355362
}
356363

357-
// The non-allocating forms of the constructors and destructors.
358-
if (auto ctor = dyn_cast<ConstructorDecl>(value)) {
359-
addSymbol(SILDeclRef(ctor, SILDeclRef::Kind::Initializer));
360-
} else if (auto dtor = dyn_cast<DestructorDecl>(value)) {
364+
// The non-allocating forms of the destructors.
365+
if (auto dtor = dyn_cast<DestructorDecl>(value)) {
361366
// ObjC classes don't have a symbol for their destructor.
362367
if (!isObjC)
363368
addSymbol(SILDeclRef(dtor, SILDeclRef::Kind::Destroyer));
@@ -367,6 +372,16 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
367372
visitNominalTypeDecl(CD);
368373
}
369374

375+
void TBDGenVisitor::visitConstructorDecl(ConstructorDecl *CD) {
376+
if (CD->getParent()->getAsClassOrClassExtensionContext()) {
377+
// Class constructors come in two forms, allocating and non-allocating. The
378+
// default ValueDecl handling gives the allocating one, so we have to
379+
// manually include the non-allocating one.
380+
addSymbol(SILDeclRef(CD, SILDeclRef::Kind::Initializer));
381+
}
382+
visitAbstractFunctionDecl(CD);
383+
}
384+
370385
void TBDGenVisitor::visitExtensionDecl(ExtensionDecl *ED) {
371386
if (!ED->getExtendedType()->isExistentialType()) {
372387
addConformances(ED);
@@ -380,14 +395,15 @@ void TBDGenVisitor::visitProtocolDecl(ProtocolDecl *PD) {
380395
addSymbol(LinkEntity::forProtocolDescriptor(PD));
381396

382397
#ifndef NDEBUG
383-
// There's no (currently) relevant information about members of a protocol
384-
// at individual protocols, each conforming type has to handle them
385-
// individually. Let's assert this fact:
398+
// There's no (currently) relevant information about members of a protocol at
399+
// individual protocols, each conforming type has to handle them individually
400+
// (NB. anything within an active IfConfigDecls also appears outside). Let's
401+
// assert this fact:
386402
for (auto *member : PD->getMembers()) {
387403
auto isExpectedKind =
388404
isa<TypeAliasDecl>(member) || isa<AssociatedTypeDecl>(member) ||
389405
isa<AbstractStorageDecl>(member) || isa<PatternBindingDecl>(member) ||
390-
isa<AbstractFunctionDecl>(member);
406+
isa<AbstractFunctionDecl>(member) || isa<IfConfigDecl>(member);
391407
assert(isExpectedKind &&
392408
"unexpected member of protocol during TBD generation");
393409
}

stdlib/public/SwiftShims/DispatchOverlayShims.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static inline void _swift_dispatch_apply_current(
166166
}
167167

168168
SWIFT_DISPATCH_RETURNS_RETAINED
169-
__swift_shims_dispatch_data_t
169+
static inline __swift_shims_dispatch_data_t
170170
_swift_dispatch_data_create(
171171
const void *buffer,
172172
size_t size,
@@ -177,7 +177,7 @@ _swift_dispatch_data_create(
177177

178178
typedef unsigned int (^__swift_shims_dispatch_data_applier)(__swift_shims_dispatch_data_t, size_t, const void *, size_t);
179179

180-
unsigned int
180+
static inline unsigned int
181181
_swift_dispatch_data_apply(
182182
__swift_shims_dispatch_data_t data,
183183
__swift_shims_dispatch_data_applier SWIFT_DISPATCH_NOESCAPE applier) {
@@ -186,19 +186,19 @@ _swift_dispatch_data_apply(
186186
});
187187
}
188188

189-
void _swift_dispatch_source_set_event_handler(
189+
static inline void _swift_dispatch_source_set_event_handler(
190190
dispatch_source_t source,
191191
__swift_shims_dispatch_block_t _Nullable block) {
192192
dispatch_source_set_event_handler(source, block);
193193
}
194194

195-
void _swift_dispatch_source_set_cancel_handler(
195+
static inline void _swift_dispatch_source_set_cancel_handler(
196196
dispatch_source_t source,
197197
__swift_shims_dispatch_block_t _Nullable block) {
198198
dispatch_source_set_cancel_handler(source, block);
199199
}
200200

201-
void _swift_dispatch_source_set_registration_handler(
201+
static inline void _swift_dispatch_source_set_registration_handler(
202202
dispatch_source_t source,
203203
__swift_shims_dispatch_block_t _Nullable block) {
204204
dispatch_source_set_registration_handler(source, block);

stdlib/public/SwiftShims/NSIndexSetShims.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ NS_BEGIN_DECLS
2020
- (NSUInteger)_indexOfRangeContainingIndex:(NSUInteger)value;
2121
@end
2222

23-
extern NSUInteger __NSIndexSetRangeCount(NS_NON_BRIDGED(NSIndexSet *)self_) {
23+
NS_INLINE NSUInteger __NSIndexSetRangeCount(NS_NON_BRIDGED(NSIndexSet *)self_) {
2424
return [(NSIndexSet *)self_ rangeCount];
2525
}
2626

27-
extern void __NSIndexSetRangeAtIndex(NS_NON_BRIDGED(NSIndexSet *)self_, NSUInteger rangeIndex, NSUInteger *location, NSUInteger *length) {
27+
NS_INLINE void __NSIndexSetRangeAtIndex(NS_NON_BRIDGED(NSIndexSet *)self_, NSUInteger rangeIndex, NSUInteger *location, NSUInteger *length) {
2828
NSRange result = [(NSIndexSet *)self_ rangeAtIndex:rangeIndex];
2929
*location = result.location;
3030
*length = result.length;

0 commit comments

Comments
 (0)