@@ -920,8 +920,6 @@ bool SILFunction::hasName(const char *Name) const {
920
920
Checks if this (callee) function body can be inlined into the caller
921
921
by comparing their SerializedKind_t values.
922
922
923
- If the \p assumeFragileCaller is true, the caller must be serialized,
924
- in which case the callee needs to be serialized also to be inlined.
925
923
If both callee and caller are not_serialized, the callee can be inlined
926
924
into the caller during SIL inlining passes even if it (and the caller)
927
925
might contain private symbols. If this callee is serialized_for_pkg, it
@@ -934,22 +932,13 @@ Callee serialized_for_pkg | ok | ok | no
934
932
serialized | ok | ok | ok
935
933
936
934
*/
937
- bool SILFunction::canBeInlinedIntoCaller (
938
- std::optional<SerializedKind_t> callerSerializedKind,
939
- bool assumeFragileCaller) const {
940
- // If the \p assumeFragileCaller is true, the caller must
941
- // be serialized, so return true only if the callee is also
942
- // serialized.
943
- if (assumeFragileCaller)
944
- return isSerialized ();
945
-
935
+ bool SILFunction::canBeInlinedIntoCaller (SerializedKind_t callerSerializedKind) const {
946
936
switch (getSerializedKind ()) {
947
937
// If both callee and caller are not_serialized, the callee
948
938
// can be inlined into the caller during SIL inlining passes
949
939
// even if it (and the caller) might contain private symbols.
950
940
case IsNotSerialized:
951
- return callerSerializedKind.has_value () &&
952
- callerSerializedKind.value () == IsNotSerialized;
941
+ return callerSerializedKind == IsNotSerialized;
953
942
954
943
// If Package-CMO is enabled, we serialize package, public,
955
944
// and @usableFromInline decls as [serialized_for_package].
@@ -962,8 +951,7 @@ bool SILFunction::canBeInlinedIntoCaller(
962
951
// for this callee's body to be inlined into the caller.
963
952
// It can however be referenced by [serialized] caller.
964
953
case IsSerializedForPackage:
965
- return callerSerializedKind.has_value () &&
966
- callerSerializedKind.value () != IsSerialized;
954
+ return callerSerializedKind != IsSerialized;
967
955
case IsSerialized:
968
956
return true ;
969
957
}
@@ -972,16 +960,18 @@ bool SILFunction::canBeInlinedIntoCaller(
972
960
973
961
// / Returns true if this function can be referenced from a fragile function
974
962
// / body.
975
- bool SILFunction::hasValidLinkageForFragileRef (
976
- std::optional<SerializedKind_t> callerSerializedKind,
977
- bool assumeFragileCaller) const {
963
+ bool SILFunction::hasValidLinkageForFragileRef (SerializedKind_t callerSerializedKind) const {
978
964
// Fragile functions can reference 'static inline' functions imported
979
965
// from C.
980
966
if (hasForeignBody ())
981
967
return true ;
982
968
969
+ // The call site of this function must have checked that
970
+ // caller.isAnySerialized() is true, as indicated by the
971
+ // function name itself (contains 'ForFragileRef').
972
+ assert (callerSerializedKind != IsNotSerialized);
983
973
// If we can inline it, we can reference it.
984
- if (canBeInlinedIntoCaller (callerSerializedKind, assumeFragileCaller ))
974
+ if (canBeInlinedIntoCaller (callerSerializedKind))
985
975
return true ;
986
976
987
977
// If the containing module has been serialized already, we no longer
0 commit comments