@@ -364,11 +364,7 @@ class SILFunction
364
364
unsigned Transparent : 1 ;
365
365
366
366
// / The function's serialized attribute.
367
- bool Serialized : 1 ;
368
-
369
- // / [serialized_for_package] attribute if package serialization
370
- // / is enabled.
371
- bool SerializedForPackage : 1 ;
367
+ unsigned SerializedKind : 2 ;
372
368
373
369
// / Specifies if this function is a thunk or a reabstraction thunk.
374
370
// /
@@ -508,7 +504,7 @@ class SILFunction
508
504
SILFunction (SILModule &module , SILLinkage linkage, StringRef mangledName,
509
505
CanSILFunctionType loweredType, GenericEnvironment *genericEnv,
510
506
IsBare_t isBareSILFunction, IsTransparent_t isTrans,
511
- IsSerialized_t isSerialized , ProfileCounter entryCount,
507
+ SerializedKind_t serializedKind , ProfileCounter entryCount,
512
508
IsThunk_t isThunk, SubclassScope classSubclassScope,
513
509
Inline_t inlineStrategy, EffectsKind E,
514
510
const SILDebugScope *debugScope,
@@ -521,7 +517,7 @@ class SILFunction
521
517
create (SILModule &M, SILLinkage linkage, StringRef name,
522
518
CanSILFunctionType loweredType, GenericEnvironment *genericEnv,
523
519
std::optional<SILLocation> loc, IsBare_t isBareSILFunction,
524
- IsTransparent_t isTrans, IsSerialized_t isSerialized ,
520
+ IsTransparent_t isTrans, SerializedKind_t serializedKind ,
525
521
ProfileCounter entryCount, IsDynamicallyReplaceable_t isDynamic,
526
522
IsDistributed_t isDistributed,
527
523
IsRuntimeAccessible_t isRuntimeAccessible,
@@ -534,7 +530,7 @@ class SILFunction
534
530
535
531
void init (SILLinkage Linkage, StringRef Name, CanSILFunctionType LoweredType,
536
532
GenericEnvironment *genericEnv, IsBare_t isBareSILFunction,
537
- IsTransparent_t isTrans, IsSerialized_t isSerialized ,
533
+ IsTransparent_t isTrans, SerializedKind_t serializedKind ,
538
534
ProfileCounter entryCount, IsThunk_t isThunk,
539
535
SubclassScope classSubclassScope, Inline_t inlineStrategy,
540
536
EffectsKind E, const SILDebugScope *DebugScope,
@@ -879,11 +875,19 @@ class SILFunction
879
875
880
876
// / Returns true if this function can be inlined into a fragile function
881
877
// / body.
882
- bool hasValidLinkageForFragileInline () const { return isSerialized (); }
878
+ // / If the caller is [serialized] due to explicit `@inlinable` but
879
+ // / the callee was [serialized_for_package] due to package-cmo, the
880
+ // / callee is [serialized] and might contain loadable types, which
881
+ // / is normally disallowed. This check prevents such loadable types
882
+ // / from being inlined.
883
+ bool canBeSerializedIntoCaller (
884
+ std::optional<SerializedKind_t> callerSerializedKind) const ;
883
885
884
886
// / Returns true if this function can be referenced from a fragile function
885
887
// / body.
886
- bool hasValidLinkageForFragileRef () const ;
888
+ bool hasValidLinkageForFragileRef (
889
+ std::optional<SerializedKind_t> callerSerializedKind =
890
+ std::nullopt ) const ;
887
891
888
892
// / Get's the effective linkage which is used to derive the llvm linkage.
889
893
// / Usually this is the same as getLinkage(), except in one case: if this
@@ -1137,28 +1141,24 @@ class SILFunction
1137
1141
assert (!Transparent || !IsDynamicReplaceable);
1138
1142
}
1139
1143
1140
- // / Get this function's serialized attribute.
1141
- IsSerialized_t isSerialized () const { return IsSerialized_t (Serialized); }
1142
- void setSerialized (IsSerialized_t isSerialized) {
1143
- Serialized = isSerialized;
1144
- assert (this ->isSerialized () == isSerialized &&
1145
- " too few bits for Serialized storage" );
1144
+ bool isSerialized () const {
1145
+ return SerializedKind_t (SerializedKind) == IsSerialized;
1146
+ }
1147
+ bool isSerializedForPackage () const {
1148
+ return SerializedKind_t (SerializedKind) == IsSerializedForPackage;
1149
+ }
1150
+ bool isNotSerialized () const {
1151
+ return SerializedKind_t (SerializedKind) == IsNotSerialized;
1146
1152
}
1147
1153
1148
- // / A [serialized_for_package] attribute is used to indicate that a function
1149
- // / is [serialized] because of package-cmo optimization.
1150
- // / Package-cmo allows serializing a function containing a loadable type in
1151
- // / a resiliently built module, which is normally illegal. During SIL deserialization,
1152
- // / this attribute can be used to check whether a loaded function that was serialized
1153
- // / can be allowed to have loadable types. This attribute is also used to determine
1154
- // / if a callee can be inlined into a caller that's serialized without package-cmo, for
1155
- // / example, by explicitly annotating the caller decl with `@inlinable`.
1156
- IsSerializedForPackage_t isSerializedForPackage () const {
1157
- return IsSerializedForPackage_t (SerializedForPackage);
1154
+ // / Get this function's serialized attribute.
1155
+ SerializedKind_t getSerializedKind () const {
1156
+ return SerializedKind_t (SerializedKind);
1158
1157
}
1159
- void
1160
- setSerializedForPackage (IsSerializedForPackage_t isSerializedForPackage) {
1161
- SerializedForPackage = isSerializedForPackage;
1158
+ void setSerializedKind (SerializedKind_t serializedKind) {
1159
+ SerializedKind = serializedKind;
1160
+ assert (this ->getSerializedKind () == serializedKind &&
1161
+ " too few bits for Serialized storage" );
1162
1162
}
1163
1163
1164
1164
// / Get this function's thunk attribute.
0 commit comments