mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #8407 from slavapestov/rename-everything-without-asking-permission
SIL: Terminology change: [fragile] => [serialized]
This commit is contained in:
@@ -582,7 +582,7 @@ public:
|
||||
return false;
|
||||
|
||||
SILFunction *F = getSILFunction();
|
||||
return F->isTransparent() && F->isDefinition() && F->isFragile();
|
||||
return F->isTransparent() && F->isDefinition() && F->isSerialized();
|
||||
}
|
||||
|
||||
SILGlobalVariable *getSILGlobalVariable() const {
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace swift {
|
||||
class ClassDecl;
|
||||
class SILFunctionType;
|
||||
enum class SILLinkage : unsigned char;
|
||||
enum IsSerialized_t : unsigned char;
|
||||
class SILModule;
|
||||
class SILLocation;
|
||||
class AnyFunctionRef;
|
||||
@@ -263,7 +264,7 @@ struct SILDeclRef {
|
||||
/// \brief True if the function should be treated as transparent.
|
||||
bool isTransparent() const;
|
||||
/// \brief True if the function should have its body serialized.
|
||||
bool isFragile() const;
|
||||
IsSerialized_t isSerialized() const;
|
||||
/// \brief True if the function has noinline attribute.
|
||||
bool isNoinline() const;
|
||||
/// \brief True if the function has __always inline attribute.
|
||||
|
||||
@@ -147,14 +147,10 @@ private:
|
||||
unsigned Bare : 1;
|
||||
|
||||
/// The function's transparent attribute.
|
||||
unsigned Transparent : 1; // FIXME: pack this somewhere
|
||||
unsigned Transparent : 1;
|
||||
|
||||
/// The function's fragile attribute.
|
||||
///
|
||||
/// Fragile means that the function can be inlined into another module.
|
||||
/// Currently this flag is set for public transparent functions and for all
|
||||
/// functions in the stdlib.
|
||||
unsigned Fragile : 1;
|
||||
/// The function's serialized attribute.
|
||||
unsigned Serialized : 2;
|
||||
|
||||
/// Specifies if this function is a thunk or a reabstraction thunk.
|
||||
///
|
||||
@@ -218,16 +214,17 @@ private:
|
||||
SILFunction(SILModule &module, SILLinkage linkage, StringRef mangledName,
|
||||
CanSILFunctionType loweredType, GenericEnvironment *genericEnv,
|
||||
Optional<SILLocation> loc, IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTrans, IsFragile_t isFragile, IsThunk_t isThunk,
|
||||
ClassVisibility_t classVisibility, Inline_t inlineStrategy,
|
||||
EffectsKind E, SILFunction *insertBefore,
|
||||
IsTransparent_t isTrans, IsSerialized_t isSerialized,
|
||||
IsThunk_t isThunk, ClassVisibility_t classVisibility,
|
||||
Inline_t inlineStrategy, EffectsKind E,
|
||||
SILFunction *insertBefore,
|
||||
const SILDebugScope *debugScope);
|
||||
|
||||
static SILFunction *
|
||||
create(SILModule &M, SILLinkage linkage, StringRef name,
|
||||
CanSILFunctionType loweredType, GenericEnvironment *genericEnv,
|
||||
Optional<SILLocation> loc, IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTrans, IsFragile_t isFragile,
|
||||
IsTransparent_t isTrans, IsSerialized_t isSerialized,
|
||||
IsThunk_t isThunk = IsNotThunk,
|
||||
ClassVisibility_t classVisibility = NotRelevant,
|
||||
Inline_t inlineStrategy = InlineDefault,
|
||||
@@ -385,7 +382,7 @@ public:
|
||||
/// Returns true if this function can be inlined into a fragile function
|
||||
/// body.
|
||||
bool hasValidLinkageForFragileInline() const {
|
||||
return isFragile() || isThunk() == IsReabstractionThunk;
|
||||
return isSerialized() || isThunk() == IsReabstractionThunk;
|
||||
}
|
||||
|
||||
/// Returns true if this function can be referenced from a fragile function
|
||||
@@ -515,9 +512,9 @@ public:
|
||||
IsTransparent_t isTransparent() const { return IsTransparent_t(Transparent); }
|
||||
void setTransparent(IsTransparent_t isT) { Transparent = isT; }
|
||||
|
||||
/// Get this function's fragile attribute.
|
||||
IsFragile_t isFragile() const { return IsFragile_t(Fragile); }
|
||||
void setFragile(IsFragile_t isFrag) { Fragile = isFrag; }
|
||||
/// Get this function's serialized attribute.
|
||||
IsSerialized_t isSerialized() const { return IsSerialized_t(Serialized); }
|
||||
void setSerialized(IsSerialized_t isSerialized) { Serialized = isSerialized; }
|
||||
|
||||
/// Get this function's thunk attribute.
|
||||
IsThunk_t isThunk() const { return IsThunk_t(Thunk); }
|
||||
|
||||
@@ -58,10 +58,10 @@ private:
|
||||
/// The linkage of the global variable.
|
||||
unsigned Linkage : NumSILLinkageBits;
|
||||
|
||||
/// The global variable's fragile attribute.
|
||||
/// Fragile means that the variable can be "inlined" into another module.
|
||||
/// The global variable's serialized attribute.
|
||||
/// Serialized means that the variable can be "inlined" into another module.
|
||||
/// Currently this flag is set for all global variables in the stdlib.
|
||||
unsigned Fragile : 1;
|
||||
unsigned Serialized : 1;
|
||||
|
||||
/// Whether this is a 'let' property, which can only be initialized
|
||||
/// once (either in its declaration, or once later), making it immutable.
|
||||
@@ -76,13 +76,14 @@ private:
|
||||
/// The static initializer.
|
||||
SILFunction *InitializerF;
|
||||
|
||||
SILGlobalVariable(SILModule &M, SILLinkage linkage, bool IsFragile,
|
||||
SILGlobalVariable(SILModule &M, SILLinkage linkage,
|
||||
IsSerialized_t IsSerialized,
|
||||
StringRef mangledName, SILType loweredType,
|
||||
Optional<SILLocation> loc, VarDecl *decl);
|
||||
|
||||
public:
|
||||
static SILGlobalVariable *create(SILModule &Module, SILLinkage Linkage,
|
||||
bool IsFragile,
|
||||
IsSerialized_t IsSerialized,
|
||||
StringRef MangledName, SILType LoweredType,
|
||||
Optional<SILLocation> Loc = None,
|
||||
VarDecl *Decl = nullptr);
|
||||
@@ -107,9 +108,9 @@ public:
|
||||
SILLinkage getLinkage() const { return SILLinkage(Linkage); }
|
||||
void setLinkage(SILLinkage linkage) { Linkage = unsigned(linkage); }
|
||||
|
||||
/// Get this global variable's fragile attribute.
|
||||
bool isFragile() const { return Fragile != 0; }
|
||||
void setFragile(bool isFrag) { Fragile = isFrag ? 1 : 0; }
|
||||
/// Get this global variable's serialized attribute.
|
||||
IsSerialized_t isSerialized() const;
|
||||
void setSerialized(IsSerialized_t isSerialized);
|
||||
|
||||
/// Is this an immutable 'let' property?
|
||||
bool isLet() const { return IsLet; }
|
||||
|
||||
@@ -86,10 +86,15 @@ enum {
|
||||
NumSILLinkageBits = 3
|
||||
};
|
||||
|
||||
/// Related to linkage: flag if a function or global variable is fragile.
|
||||
enum IsFragile_t {
|
||||
IsNotFragile,
|
||||
IsFragile
|
||||
/// Related to linkage: flag if a function or global variable is serialized,
|
||||
/// either unconditionally, or if referenced from another serialized function.
|
||||
enum IsSerialized_t : unsigned char {
|
||||
// Never serialized.
|
||||
IsNotSerialized,
|
||||
// Serialized if referenced from another serialized function.
|
||||
IsSerializable,
|
||||
// Always serialized.
|
||||
IsSerialized
|
||||
};
|
||||
|
||||
/// Strip external from public_external, hidden_external. Otherwise just return
|
||||
|
||||
@@ -266,7 +266,7 @@ public:
|
||||
/// source file, starting from the specified element number.
|
||||
///
|
||||
/// If \p makeModuleFragile is true, all functions and global variables of
|
||||
/// the module are marked as fragile. This is used for compiling the stdlib.
|
||||
/// the module are marked as serialized. This is used for compiling the stdlib.
|
||||
static std::unique_ptr<SILModule>
|
||||
constructSIL(ModuleDecl *M, SILOptions &Options, FileUnit *sf = nullptr,
|
||||
Optional<unsigned> startElem = None,
|
||||
@@ -466,7 +466,7 @@ public:
|
||||
CanSILFunctionType type,
|
||||
IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTransparent,
|
||||
IsFragile_t isFragile,
|
||||
IsSerialized_t isSerialized,
|
||||
IsThunk_t isThunk);
|
||||
|
||||
/// \brief Return the declaration of a function, or create it if it doesn't
|
||||
@@ -477,7 +477,7 @@ public:
|
||||
CanSILFunctionType type,
|
||||
IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTransparent,
|
||||
IsFragile_t isFragile,
|
||||
IsSerialized_t isSerialized,
|
||||
IsThunk_t isThunk = IsNotThunk,
|
||||
SILFunction::ClassVisibility_t CV =
|
||||
SILFunction::NotRelevant);
|
||||
@@ -497,7 +497,7 @@ public:
|
||||
SILLinkage linkage, StringRef name, CanSILFunctionType loweredType,
|
||||
GenericEnvironment *genericEnv, Optional<SILLocation> loc,
|
||||
IsBare_t isBareSILFunction, IsTransparent_t isTrans,
|
||||
IsFragile_t isFragile, IsThunk_t isThunk = IsNotThunk,
|
||||
IsSerialized_t isSerialized, IsThunk_t isThunk = IsNotThunk,
|
||||
SILFunction::ClassVisibility_t classVisibility = SILFunction::NotRelevant,
|
||||
Inline_t inlineStrategy = InlineDefault,
|
||||
EffectsKind EK = EffectsKind::Unspecified,
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace swift {
|
||||
class SILFunction;
|
||||
class SILModule;
|
||||
class NormalProtocolConformance;
|
||||
enum IsSerialized_t : unsigned char;
|
||||
|
||||
/// A mapping from each requirement of a protocol to the SIL-level entity
|
||||
/// satisfying the requirement for a concrete type.
|
||||
@@ -190,13 +191,13 @@ private:
|
||||
/// that is not a declaration.
|
||||
bool IsDeclaration;
|
||||
|
||||
/// Whether or not this witness table is fragile. Fragile means that the
|
||||
/// table may be serialized and "inlined" into another module.
|
||||
bool IsFragile;
|
||||
/// Whether or not this witness table is serialized, which allows
|
||||
/// devirtualization from another module.
|
||||
bool Serialized;
|
||||
|
||||
/// Private constructor for making SILWitnessTable definitions.
|
||||
SILWitnessTable(SILModule &M, SILLinkage Linkage,
|
||||
bool IsFragile, StringRef Name,
|
||||
IsSerialized_t Serialized, StringRef Name,
|
||||
NormalProtocolConformance *Conformance,
|
||||
ArrayRef<Entry> entries);
|
||||
|
||||
@@ -209,7 +210,7 @@ private:
|
||||
public:
|
||||
/// Create a new SILWitnessTable definition with the given entries.
|
||||
static SILWitnessTable *create(SILModule &M, SILLinkage Linkage,
|
||||
bool IsFragile,
|
||||
IsSerialized_t Serialized,
|
||||
NormalProtocolConformance *Conformance,
|
||||
ArrayRef<Entry> entries);
|
||||
|
||||
@@ -236,8 +237,8 @@ public:
|
||||
/// Returns true if this witness table is a definition.
|
||||
bool isDefinition() const { return !isDeclaration(); }
|
||||
|
||||
/// Returns true if this witness table is fragile.
|
||||
bool isFragile() const { return IsFragile; }
|
||||
/// Returns true if this witness table is going to be (or was) serialized.
|
||||
IsSerialized_t isSerialized() const;
|
||||
|
||||
/// Return all of the witness table entries.
|
||||
ArrayRef<Entry> getEntries() const { return Entries; }
|
||||
@@ -265,7 +266,8 @@ public:
|
||||
void setLinkage(SILLinkage l) { Linkage = l; }
|
||||
|
||||
/// Change a SILWitnessTable declaration into a SILWitnessTable definition.
|
||||
void convertToDefinition(ArrayRef<Entry> newEntries, bool isFragile);
|
||||
void convertToDefinition(ArrayRef<Entry> newEntries,
|
||||
IsSerialized_t isSerialized);
|
||||
|
||||
/// Print the witness table.
|
||||
void print(llvm::raw_ostream &OS, bool Verbose = false) const;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace swift {
|
||||
|
||||
class GenericCloner : public TypeSubstCloner<GenericCloner> {
|
||||
IsFragile_t Fragile;
|
||||
IsSerialized_t Serialized;
|
||||
const ReabstractionInfo &ReInfo;
|
||||
CloneCollector::CallbackType Callback;
|
||||
|
||||
@@ -39,12 +39,12 @@ public:
|
||||
friend class SILCloner<GenericCloner>;
|
||||
|
||||
GenericCloner(SILFunction *F,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
const ReabstractionInfo &ReInfo,
|
||||
SubstitutionList ParamSubs,
|
||||
StringRef NewName,
|
||||
CloneCollector::CallbackType Callback)
|
||||
: TypeSubstCloner(*initCloned(F, Fragile, ReInfo, NewName), *F,
|
||||
: TypeSubstCloner(*initCloned(F, Serialized, ReInfo, NewName), *F,
|
||||
ParamSubs), ReInfo(ReInfo), Callback(Callback) {
|
||||
assert(F->getDebugScope()->Parent != getCloned()->getDebugScope()->Parent);
|
||||
}
|
||||
@@ -53,13 +53,13 @@ public:
|
||||
/// direct) according to \p ReInfo.
|
||||
static SILFunction *
|
||||
cloneFunction(SILFunction *F,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
const ReabstractionInfo &ReInfo,
|
||||
SubstitutionList ParamSubs,
|
||||
StringRef NewName,
|
||||
CloneCollector::CallbackType Callback =nullptr) {
|
||||
// Clone and specialize the function.
|
||||
GenericCloner SC(F, Fragile, ReInfo, ParamSubs,
|
||||
GenericCloner SC(F, Serialized, ReInfo, ParamSubs,
|
||||
NewName, Callback);
|
||||
SC.populateCloned();
|
||||
SC.cleanUp(SC.getCloned());
|
||||
@@ -83,7 +83,7 @@ protected:
|
||||
|
||||
private:
|
||||
static SILFunction *initCloned(SILFunction *Orig,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
const ReabstractionInfo &ReInfo,
|
||||
StringRef NewName);
|
||||
/// Clone the body of the function into the empty function that was created
|
||||
|
||||
@@ -250,7 +250,7 @@ class GenericFuncSpecializer {
|
||||
SILModule &M;
|
||||
SILFunction *GenericFunc;
|
||||
SubstitutionList ParamSubs;
|
||||
IsFragile_t Fragile;
|
||||
IsSerialized_t Serialized;
|
||||
const ReabstractionInfo &ReInfo;
|
||||
|
||||
SubstitutionMap ContextSubs;
|
||||
@@ -259,7 +259,7 @@ class GenericFuncSpecializer {
|
||||
public:
|
||||
GenericFuncSpecializer(SILFunction *GenericFunc,
|
||||
SubstitutionList ParamSubs,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
const ReabstractionInfo &ReInfo);
|
||||
|
||||
/// If we already have this specialization, reuse it.
|
||||
|
||||
@@ -37,7 +37,7 @@ protected:
|
||||
/// The specialization pass.
|
||||
SpecializationPass Pass;
|
||||
|
||||
IsFragile_t Fragile;
|
||||
IsSerialized_t Serialized;
|
||||
|
||||
/// The original function which is specialized.
|
||||
SILFunction *Function;
|
||||
@@ -46,9 +46,9 @@ protected:
|
||||
llvm::raw_svector_ostream ArgOpBuffer;
|
||||
|
||||
protected:
|
||||
SpecializationMangler(SpecializationPass P, IsFragile_t Fragile,
|
||||
SpecializationMangler(SpecializationPass P, IsSerialized_t Serialized,
|
||||
SILFunction *F)
|
||||
: Pass(P), Fragile(Fragile), Function(F), ArgOpBuffer(ArgOpStorage) {}
|
||||
: Pass(P), Serialized(Serialized), Function(F), ArgOpBuffer(ArgOpStorage) {}
|
||||
|
||||
SILFunction *getFunction() const { return Function; }
|
||||
|
||||
@@ -72,9 +72,9 @@ public:
|
||||
|
||||
GenericSpecializationMangler(SILFunction *F,
|
||||
SubstitutionList Subs,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
bool isReAbstracted)
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer, Fragile, F),
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
|
||||
Subs(Subs), isReAbstracted(isReAbstracted) {}
|
||||
|
||||
std::string mangle();
|
||||
@@ -88,9 +88,9 @@ class PartialSpecializationMangler : public SpecializationMangler {
|
||||
public:
|
||||
PartialSpecializationMangler(SILFunction *F,
|
||||
CanSILFunctionType SpecializedFnTy,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
bool isReAbstracted)
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer, Fragile, F),
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
|
||||
SpecializedFnTy(SpecializedFnTy), isReAbstracted(isReAbstracted) {}
|
||||
|
||||
std::string mangle();
|
||||
@@ -141,7 +141,7 @@ class FunctionSignatureSpecializationMangler : public SpecializationMangler {
|
||||
|
||||
public:
|
||||
FunctionSignatureSpecializationMangler(SpecializationPass Pass,
|
||||
IsFragile_t Fragile,
|
||||
IsSerialized_t Serialized,
|
||||
SILFunction *F);
|
||||
void setArgumentConstantProp(unsigned OrigArgIdx, LiteralInst *LI);
|
||||
void setArgumentClosureProp(unsigned OrigArgIdx, PartialApplyInst *PAI);
|
||||
|
||||
@@ -54,7 +54,7 @@ const uint16_t VERSION_MAJOR = 0;
|
||||
/// in source control, you should also update the comment to briefly
|
||||
/// describe what change you made. The content of this comment isn't important;
|
||||
/// it just ensures a conflict if two people change the module format.
|
||||
const uint16_t VERSION_MINOR = 327; // Last change: begin_access/end_access
|
||||
const uint16_t VERSION_MINOR = 328; // Last change: fragile => serialized
|
||||
|
||||
using DeclID = PointerEmbeddedInt<unsigned, 31>;
|
||||
using DeclIDField = BCFixed<31>;
|
||||
|
||||
Reference in New Issue
Block a user