Skip to content

Commit a3590a2

Browse files
committed
SIL: Replace substitutionsChangeGenericTypeParameters() with isIdentity() check
1 parent 4272552 commit a3590a2

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

include/swift/SIL/TypeSubstCloner.h

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -375,31 +375,6 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
375375
getOpValue(dfei->getOperand()), remappedDerivativeFnType));
376376
}
377377

378-
/// One abstract function in the debug info can only have one set of variables
379-
/// and types. This function determines whether applying the substitutions in
380-
/// \p SubsMap on the generic signature \p Sig will change the generic type
381-
/// parameters in the signature. This is used to decide whether it's necessary
382-
/// to clone a unique copy of the function declaration with the substitutions
383-
/// applied for the debug info.
384-
static bool substitutionsChangeGenericTypeParameters(SubstitutionMap SubsMap,
385-
GenericSignature Sig) {
386-
387-
// If there are no substitutions, just reuse
388-
// the original decl.
389-
if (SubsMap.empty())
390-
return false;
391-
392-
bool Result = false;
393-
Sig->forEachParam([&](GenericTypeParamType *ParamType, bool Canonical) {
394-
if (!Canonical)
395-
return;
396-
if (!Type(ParamType).subst(SubsMap)->isEqual(ParamType))
397-
Result = true;
398-
});
399-
400-
return Result;
401-
}
402-
403378
enum { ForInlining = true };
404379
/// Helper function to clone the parent function of a SILDebugScope if
405380
/// necessary when inlining said function into a new generic context.
@@ -420,7 +395,11 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
420395
if (SubsMap.hasArchetypes())
421396
SubsMap = SubsMap.mapReplacementTypesOutOfContext();
422397

423-
if (!substitutionsChangeGenericTypeParameters(SubsMap, RemappedSig))
398+
// One abstract function in the debug info can only have one set of variables
399+
// and types. We check if the function is called with non-identity substitutions
400+
// to decide whether it's necessary to clone a unique copy of the function
401+
// declaration with the substitutions applied for the debug info.
402+
if (SubsMap.isIdentity())
424403
return ParentFunction;
425404

426405
// Note that mapReplacementTypesOutOfContext() can't do anything for

0 commit comments

Comments
 (0)