Skip to content

Commit 695a8d2

Browse files
authored
Merge pull request #8407 from slavapestov/rename-everything-without-asking-permission
SIL: Terminology change: [fragile] => [serialized]
2 parents 0ccbfdb + 8fe8b89 commit 695a8d2

File tree

129 files changed

+830
-792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+830
-792
lines changed

include/swift/IRGen/LinkEntity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ class LinkEntity {
582582
return false;
583583

584584
SILFunction *F = getSILFunction();
585-
return F->isTransparent() && F->isDefinition() && F->isFragile();
585+
return F->isTransparent() && F->isDefinition() && F->isSerialized();
586586
}
587587

588588
SILGlobalVariable *getSILGlobalVariable() const {

include/swift/SIL/SILDeclRef.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace swift {
4343
class ClassDecl;
4444
class SILFunctionType;
4545
enum class SILLinkage : unsigned char;
46+
enum IsSerialized_t : unsigned char;
4647
class SILModule;
4748
class SILLocation;
4849
class AnyFunctionRef;
@@ -263,7 +264,7 @@ struct SILDeclRef {
263264
/// \brief True if the function should be treated as transparent.
264265
bool isTransparent() const;
265266
/// \brief True if the function should have its body serialized.
266-
bool isFragile() const;
267+
IsSerialized_t isSerialized() const;
267268
/// \brief True if the function has noinline attribute.
268269
bool isNoinline() const;
269270
/// \brief True if the function has __always inline attribute.

include/swift/SIL/SILFunction.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,10 @@ class SILFunction
147147
unsigned Bare : 1;
148148

149149
/// The function's transparent attribute.
150-
unsigned Transparent : 1; // FIXME: pack this somewhere
150+
unsigned Transparent : 1;
151151

152-
/// The function's fragile attribute.
153-
///
154-
/// Fragile means that the function can be inlined into another module.
155-
/// Currently this flag is set for public transparent functions and for all
156-
/// functions in the stdlib.
157-
unsigned Fragile : 1;
152+
/// The function's serialized attribute.
153+
unsigned Serialized : 2;
158154

159155
/// Specifies if this function is a thunk or a reabstraction thunk.
160156
///
@@ -218,16 +214,17 @@ class SILFunction
218214
SILFunction(SILModule &module, SILLinkage linkage, StringRef mangledName,
219215
CanSILFunctionType loweredType, GenericEnvironment *genericEnv,
220216
Optional<SILLocation> loc, IsBare_t isBareSILFunction,
221-
IsTransparent_t isTrans, IsFragile_t isFragile, IsThunk_t isThunk,
222-
ClassVisibility_t classVisibility, Inline_t inlineStrategy,
223-
EffectsKind E, SILFunction *insertBefore,
217+
IsTransparent_t isTrans, IsSerialized_t isSerialized,
218+
IsThunk_t isThunk, ClassVisibility_t classVisibility,
219+
Inline_t inlineStrategy, EffectsKind E,
220+
SILFunction *insertBefore,
224221
const SILDebugScope *debugScope);
225222

226223
static SILFunction *
227224
create(SILModule &M, SILLinkage linkage, StringRef name,
228225
CanSILFunctionType loweredType, GenericEnvironment *genericEnv,
229226
Optional<SILLocation> loc, IsBare_t isBareSILFunction,
230-
IsTransparent_t isTrans, IsFragile_t isFragile,
227+
IsTransparent_t isTrans, IsSerialized_t isSerialized,
231228
IsThunk_t isThunk = IsNotThunk,
232229
ClassVisibility_t classVisibility = NotRelevant,
233230
Inline_t inlineStrategy = InlineDefault,
@@ -385,7 +382,7 @@ class SILFunction
385382
/// Returns true if this function can be inlined into a fragile function
386383
/// body.
387384
bool hasValidLinkageForFragileInline() const {
388-
return isFragile() || isThunk() == IsReabstractionThunk;
385+
return isSerialized() || isThunk() == IsReabstractionThunk;
389386
}
390387

391388
/// Returns true if this function can be referenced from a fragile function
@@ -515,9 +512,9 @@ class SILFunction
515512
IsTransparent_t isTransparent() const { return IsTransparent_t(Transparent); }
516513
void setTransparent(IsTransparent_t isT) { Transparent = isT; }
517514

518-
/// Get this function's fragile attribute.
519-
IsFragile_t isFragile() const { return IsFragile_t(Fragile); }
520-
void setFragile(IsFragile_t isFrag) { Fragile = isFrag; }
515+
/// Get this function's serialized attribute.
516+
IsSerialized_t isSerialized() const { return IsSerialized_t(Serialized); }
517+
void setSerialized(IsSerialized_t isSerialized) { Serialized = isSerialized; }
521518

522519
/// Get this function's thunk attribute.
523520
IsThunk_t isThunk() const { return IsThunk_t(Thunk); }

include/swift/SIL/SILGlobalVariable.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class SILGlobalVariable
5858
/// The linkage of the global variable.
5959
unsigned Linkage : NumSILLinkageBits;
6060

61-
/// The global variable's fragile attribute.
62-
/// Fragile means that the variable can be "inlined" into another module.
61+
/// The global variable's serialized attribute.
62+
/// Serialized means that the variable can be "inlined" into another module.
6363
/// Currently this flag is set for all global variables in the stdlib.
64-
unsigned Fragile : 1;
64+
unsigned Serialized : 1;
6565

6666
/// Whether this is a 'let' property, which can only be initialized
6767
/// once (either in its declaration, or once later), making it immutable.
@@ -76,13 +76,14 @@ class SILGlobalVariable
7676
/// The static initializer.
7777
SILFunction *InitializerF;
7878

79-
SILGlobalVariable(SILModule &M, SILLinkage linkage, bool IsFragile,
79+
SILGlobalVariable(SILModule &M, SILLinkage linkage,
80+
IsSerialized_t IsSerialized,
8081
StringRef mangledName, SILType loweredType,
8182
Optional<SILLocation> loc, VarDecl *decl);
8283

8384
public:
8485
static SILGlobalVariable *create(SILModule &Module, SILLinkage Linkage,
85-
bool IsFragile,
86+
IsSerialized_t IsSerialized,
8687
StringRef MangledName, SILType LoweredType,
8788
Optional<SILLocation> Loc = None,
8889
VarDecl *Decl = nullptr);
@@ -107,9 +108,9 @@ class SILGlobalVariable
107108
SILLinkage getLinkage() const { return SILLinkage(Linkage); }
108109
void setLinkage(SILLinkage linkage) { Linkage = unsigned(linkage); }
109110

110-
/// Get this global variable's fragile attribute.
111-
bool isFragile() const { return Fragile != 0; }
112-
void setFragile(bool isFrag) { Fragile = isFrag ? 1 : 0; }
111+
/// Get this global variable's serialized attribute.
112+
IsSerialized_t isSerialized() const;
113+
void setSerialized(IsSerialized_t isSerialized);
113114

114115
/// Is this an immutable 'let' property?
115116
bool isLet() const { return IsLet; }

include/swift/SIL/SILLinkage.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,15 @@ enum {
8686
NumSILLinkageBits = 3
8787
};
8888

89-
/// Related to linkage: flag if a function or global variable is fragile.
90-
enum IsFragile_t {
91-
IsNotFragile,
92-
IsFragile
89+
/// Related to linkage: flag if a function or global variable is serialized,
90+
/// either unconditionally, or if referenced from another serialized function.
91+
enum IsSerialized_t : unsigned char {
92+
// Never serialized.
93+
IsNotSerialized,
94+
// Serialized if referenced from another serialized function.
95+
IsSerializable,
96+
// Always serialized.
97+
IsSerialized
9398
};
9499

95100
/// Strip external from public_external, hidden_external. Otherwise just return

include/swift/SIL/SILModule.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class SILModule {
266266
/// source file, starting from the specified element number.
267267
///
268268
/// If \p makeModuleFragile is true, all functions and global variables of
269-
/// the module are marked as fragile. This is used for compiling the stdlib.
269+
/// the module are marked as serialized. This is used for compiling the stdlib.
270270
static std::unique_ptr<SILModule>
271271
constructSIL(ModuleDecl *M, SILOptions &Options, FileUnit *sf = nullptr,
272272
Optional<unsigned> startElem = None,
@@ -466,7 +466,7 @@ class SILModule {
466466
CanSILFunctionType type,
467467
IsBare_t isBareSILFunction,
468468
IsTransparent_t isTransparent,
469-
IsFragile_t isFragile,
469+
IsSerialized_t isSerialized,
470470
IsThunk_t isThunk);
471471

472472
/// \brief Return the declaration of a function, or create it if it doesn't
@@ -477,7 +477,7 @@ class SILModule {
477477
CanSILFunctionType type,
478478
IsBare_t isBareSILFunction,
479479
IsTransparent_t isTransparent,
480-
IsFragile_t isFragile,
480+
IsSerialized_t isSerialized,
481481
IsThunk_t isThunk = IsNotThunk,
482482
SILFunction::ClassVisibility_t CV =
483483
SILFunction::NotRelevant);
@@ -497,7 +497,7 @@ class SILModule {
497497
SILLinkage linkage, StringRef name, CanSILFunctionType loweredType,
498498
GenericEnvironment *genericEnv, Optional<SILLocation> loc,
499499
IsBare_t isBareSILFunction, IsTransparent_t isTrans,
500-
IsFragile_t isFragile, IsThunk_t isThunk = IsNotThunk,
500+
IsSerialized_t isSerialized, IsThunk_t isThunk = IsNotThunk,
501501
SILFunction::ClassVisibility_t classVisibility = SILFunction::NotRelevant,
502502
Inline_t inlineStrategy = InlineDefault,
503503
EffectsKind EK = EffectsKind::Unspecified,

include/swift/SIL/SILWitnessTable.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace swift {
3535
class SILFunction;
3636
class SILModule;
3737
class NormalProtocolConformance;
38+
enum IsSerialized_t : unsigned char;
3839

3940
/// A mapping from each requirement of a protocol to the SIL-level entity
4041
/// satisfying the requirement for a concrete type.
@@ -190,13 +191,13 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
190191
/// that is not a declaration.
191192
bool IsDeclaration;
192193

193-
/// Whether or not this witness table is fragile. Fragile means that the
194-
/// table may be serialized and "inlined" into another module.
195-
bool IsFragile;
194+
/// Whether or not this witness table is serialized, which allows
195+
/// devirtualization from another module.
196+
bool Serialized;
196197

197198
/// Private constructor for making SILWitnessTable definitions.
198199
SILWitnessTable(SILModule &M, SILLinkage Linkage,
199-
bool IsFragile, StringRef Name,
200+
IsSerialized_t Serialized, StringRef Name,
200201
NormalProtocolConformance *Conformance,
201202
ArrayRef<Entry> entries);
202203

@@ -209,7 +210,7 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
209210
public:
210211
/// Create a new SILWitnessTable definition with the given entries.
211212
static SILWitnessTable *create(SILModule &M, SILLinkage Linkage,
212-
bool IsFragile,
213+
IsSerialized_t Serialized,
213214
NormalProtocolConformance *Conformance,
214215
ArrayRef<Entry> entries);
215216

@@ -236,8 +237,8 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
236237
/// Returns true if this witness table is a definition.
237238
bool isDefinition() const { return !isDeclaration(); }
238239

239-
/// Returns true if this witness table is fragile.
240-
bool isFragile() const { return IsFragile; }
240+
/// Returns true if this witness table is going to be (or was) serialized.
241+
IsSerialized_t isSerialized() const;
241242

242243
/// Return all of the witness table entries.
243244
ArrayRef<Entry> getEntries() const { return Entries; }
@@ -265,7 +266,8 @@ class SILWitnessTable : public llvm::ilist_node<SILWitnessTable>,
265266
void setLinkage(SILLinkage l) { Linkage = l; }
266267

267268
/// Change a SILWitnessTable declaration into a SILWitnessTable definition.
268-
void convertToDefinition(ArrayRef<Entry> newEntries, bool isFragile);
269+
void convertToDefinition(ArrayRef<Entry> newEntries,
270+
IsSerialized_t isSerialized);
269271

270272
/// Print the witness table.
271273
void print(llvm::raw_ostream &OS, bool Verbose = false) const;

include/swift/SILOptimizer/Utils/GenericCloner.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@
3131
namespace swift {
3232

3333
class GenericCloner : public TypeSubstCloner<GenericCloner> {
34-
IsFragile_t Fragile;
34+
IsSerialized_t Serialized;
3535
const ReabstractionInfo &ReInfo;
3636
CloneCollector::CallbackType Callback;
3737

3838
public:
3939
friend class SILCloner<GenericCloner>;
4040

4141
GenericCloner(SILFunction *F,
42-
IsFragile_t Fragile,
42+
IsSerialized_t Serialized,
4343
const ReabstractionInfo &ReInfo,
4444
SubstitutionList ParamSubs,
4545
StringRef NewName,
4646
CloneCollector::CallbackType Callback)
47-
: TypeSubstCloner(*initCloned(F, Fragile, ReInfo, NewName), *F,
47+
: TypeSubstCloner(*initCloned(F, Serialized, ReInfo, NewName), *F,
4848
ParamSubs), ReInfo(ReInfo), Callback(Callback) {
4949
assert(F->getDebugScope()->Parent != getCloned()->getDebugScope()->Parent);
5050
}
@@ -53,13 +53,13 @@ class GenericCloner : public TypeSubstCloner<GenericCloner> {
5353
/// direct) according to \p ReInfo.
5454
static SILFunction *
5555
cloneFunction(SILFunction *F,
56-
IsFragile_t Fragile,
56+
IsSerialized_t Serialized,
5757
const ReabstractionInfo &ReInfo,
5858
SubstitutionList ParamSubs,
5959
StringRef NewName,
6060
CloneCollector::CallbackType Callback =nullptr) {
6161
// Clone and specialize the function.
62-
GenericCloner SC(F, Fragile, ReInfo, ParamSubs,
62+
GenericCloner SC(F, Serialized, ReInfo, ParamSubs,
6363
NewName, Callback);
6464
SC.populateCloned();
6565
SC.cleanUp(SC.getCloned());
@@ -83,7 +83,7 @@ class GenericCloner : public TypeSubstCloner<GenericCloner> {
8383

8484
private:
8585
static SILFunction *initCloned(SILFunction *Orig,
86-
IsFragile_t Fragile,
86+
IsSerialized_t Serialized,
8787
const ReabstractionInfo &ReInfo,
8888
StringRef NewName);
8989
/// Clone the body of the function into the empty function that was created

include/swift/SILOptimizer/Utils/Generics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class GenericFuncSpecializer {
250250
SILModule &M;
251251
SILFunction *GenericFunc;
252252
SubstitutionList ParamSubs;
253-
IsFragile_t Fragile;
253+
IsSerialized_t Serialized;
254254
const ReabstractionInfo &ReInfo;
255255

256256
SubstitutionMap ContextSubs;
@@ -259,7 +259,7 @@ class GenericFuncSpecializer {
259259
public:
260260
GenericFuncSpecializer(SILFunction *GenericFunc,
261261
SubstitutionList ParamSubs,
262-
IsFragile_t Fragile,
262+
IsSerialized_t Serialized,
263263
const ReabstractionInfo &ReInfo);
264264

265265
/// If we already have this specialization, reuse it.

include/swift/SILOptimizer/Utils/SpecializationMangler.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SpecializationMangler : public Mangle::ASTMangler {
3737
/// The specialization pass.
3838
SpecializationPass Pass;
3939

40-
IsFragile_t Fragile;
40+
IsSerialized_t Serialized;
4141

4242
/// The original function which is specialized.
4343
SILFunction *Function;
@@ -46,9 +46,9 @@ class SpecializationMangler : public Mangle::ASTMangler {
4646
llvm::raw_svector_ostream ArgOpBuffer;
4747

4848
protected:
49-
SpecializationMangler(SpecializationPass P, IsFragile_t Fragile,
49+
SpecializationMangler(SpecializationPass P, IsSerialized_t Serialized,
5050
SILFunction *F)
51-
: Pass(P), Fragile(Fragile), Function(F), ArgOpBuffer(ArgOpStorage) {}
51+
: Pass(P), Serialized(Serialized), Function(F), ArgOpBuffer(ArgOpStorage) {}
5252

5353
SILFunction *getFunction() const { return Function; }
5454

@@ -72,9 +72,9 @@ class GenericSpecializationMangler : public SpecializationMangler {
7272

7373
GenericSpecializationMangler(SILFunction *F,
7474
SubstitutionList Subs,
75-
IsFragile_t Fragile,
75+
IsSerialized_t Serialized,
7676
bool isReAbstracted)
77-
: SpecializationMangler(SpecializationPass::GenericSpecializer, Fragile, F),
77+
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
7878
Subs(Subs), isReAbstracted(isReAbstracted) {}
7979

8080
std::string mangle();
@@ -88,9 +88,9 @@ class PartialSpecializationMangler : public SpecializationMangler {
8888
public:
8989
PartialSpecializationMangler(SILFunction *F,
9090
CanSILFunctionType SpecializedFnTy,
91-
IsFragile_t Fragile,
91+
IsSerialized_t Serialized,
9292
bool isReAbstracted)
93-
: SpecializationMangler(SpecializationPass::GenericSpecializer, Fragile, F),
93+
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
9494
SpecializedFnTy(SpecializedFnTy), isReAbstracted(isReAbstracted) {}
9595

9696
std::string mangle();
@@ -141,7 +141,7 @@ class FunctionSignatureSpecializationMangler : public SpecializationMangler {
141141

142142
public:
143143
FunctionSignatureSpecializationMangler(SpecializationPass Pass,
144-
IsFragile_t Fragile,
144+
IsSerialized_t Serialized,
145145
SILFunction *F);
146146
void setArgumentConstantProp(unsigned OrigArgIdx, LiteralInst *LI);
147147
void setArgumentClosureProp(unsigned OrigArgIdx, PartialApplyInst *PAI);

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const uint16_t VERSION_MAJOR = 0;
5454
/// in source control, you should also update the comment to briefly
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
57-
const uint16_t VERSION_MINOR = 327; // Last change: begin_access/end_access
57+
const uint16_t VERSION_MINOR = 328; // Last change: fragile => serialized
5858

5959
using DeclID = PointerEmbeddedInt<unsigned, 31>;
6060
using DeclIDField = BCFixed<31>;

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,10 +1257,10 @@ bool LinkEntity::isAvailableExternally(IRGenModule &IGM) const {
12571257
bool LinkEntity::isFragile(IRGenModule &IGM) const {
12581258
switch (getKind()) {
12591259
case Kind::SILFunction:
1260-
return getSILFunction()->isFragile();
1260+
return getSILFunction()->isSerialized();
12611261

12621262
case Kind::SILGlobalVariable:
1263-
return getSILGlobalVariable()->isFragile();
1263+
return getSILGlobalVariable()->isSerialized();
12641264

12651265
case Kind::ReflectionAssociatedTypeDescriptor:
12661266
case Kind::ReflectionSuperclassDescriptor:
@@ -1283,7 +1283,7 @@ bool LinkEntity::isFragile(IRGenModule &IGM) const {
12831283
// not public, it must be fragile.
12841284
if (swift::isAvailableExternally(L) && !hasPublicVisibility(L))
12851285
return true;
1286-
return wt->isFragile();
1286+
return wt->isSerialized();
12871287
}
12881288
}
12891289
return false;

0 commit comments

Comments
 (0)