@@ -920,8 +920,6 @@ bool SILFunction::hasName(const char *Name) const {
920920 Checks if this (callee) function body can be inlined into the caller
921921 by comparing their SerializedKind_t values.
922922
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.
925923 If both callee and caller are not_serialized, the callee can be inlined
926924 into the caller during SIL inlining passes even if it (and the caller)
927925 might contain private symbols. If this callee is serialized_for_pkg, it
@@ -934,22 +932,13 @@ Callee serialized_for_pkg | ok | ok | no
934932 serialized | ok | ok | ok
935933
936934*/
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 {
946936 switch (getSerializedKind ()) {
947937 // If both callee and caller are not_serialized, the callee
948938 // can be inlined into the caller during SIL inlining passes
949939 // even if it (and the caller) might contain private symbols.
950940 case IsNotSerialized:
951- return callerSerializedKind.has_value () &&
952- callerSerializedKind.value () == IsNotSerialized;
941+ return callerSerializedKind == IsNotSerialized;
953942
954943 // If Package-CMO is enabled, we serialize package, public,
955944 // and @usableFromInline decls as [serialized_for_package].
@@ -962,8 +951,7 @@ bool SILFunction::canBeInlinedIntoCaller(
962951 // for this callee's body to be inlined into the caller.
963952 // It can however be referenced by [serialized] caller.
964953 case IsSerializedForPackage:
965- return callerSerializedKind.has_value () &&
966- callerSerializedKind.value () != IsSerialized;
954+ return callerSerializedKind != IsSerialized;
967955 case IsSerialized:
968956 return true ;
969957 }
@@ -972,16 +960,18 @@ bool SILFunction::canBeInlinedIntoCaller(
972960
973961// / Returns true if this function can be referenced from a fragile function
974962// / body.
975- bool SILFunction::hasValidLinkageForFragileRef (
976- std::optional<SerializedKind_t> callerSerializedKind,
977- bool assumeFragileCaller) const {
963+ bool SILFunction::hasValidLinkageForFragileRef (SerializedKind_t callerSerializedKind) const {
978964 // Fragile functions can reference 'static inline' functions imported
979965 // from C.
980966 if (hasForeignBody ())
981967 return true ;
982968
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);
983973 // If we can inline it, we can reference it.
984- if (canBeInlinedIntoCaller (callerSerializedKind, assumeFragileCaller ))
974+ if (canBeInlinedIntoCaller (callerSerializedKind))
985975 return true ;
986976
987977 // If the containing module has been serialized already, we no longer
0 commit comments