Skip to content

Commit 67e9b99

Browse files
authored
Merge pull request swiftlang#21470 from ravikandhadai/witnesss-method-subs-branch
2 parents 6938f1a + 92260f9 commit 67e9b99

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

include/swift/SILOptimizer/Utils/Devirtualize.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ void getAllSubclasses(ClassHierarchyAnalysis *CHA,
4848
SILModule &M,
4949
ClassHierarchyAnalysis::ClassList &Subs);
5050

51+
/// Given an apply instruction of a protocol requirement and a witness method
52+
/// for the requirement, compute a substitution suitable for a direct call
53+
/// to the witness method.
54+
///
55+
/// \p Module SILModule
56+
/// \p AI ApplySite that applies a procotol method
57+
/// \p F SILFunction with convention @convention(witness_method)
58+
/// \p CRef a concrete ProtocolConformanceRef
59+
SubstitutionMap getWitnessMethodSubstitutions(SILModule &Module, ApplySite AI,
60+
SILFunction *F,
61+
ProtocolConformanceRef CRef);
62+
5163
/// Attempt to devirtualize the given apply site. If this fails,
5264
/// the returned ApplySite will be null.
5365
///

lib/SILOptimizer/Utils/Devirtualize.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,10 @@ getWitnessMethodSubstitutions(
883883
witnessThunkSig);
884884
}
885885

886-
static SubstitutionMap
887-
getWitnessMethodSubstitutions(SILModule &Module, ApplySite AI, SILFunction *F,
888-
ProtocolConformanceRef CRef) {
886+
SubstitutionMap
887+
swift::getWitnessMethodSubstitutions(SILModule &Module, ApplySite AI,
888+
SILFunction *F,
889+
ProtocolConformanceRef CRef) {
889890
auto witnessFnTy = F->getLoweredFunctionType();
890891
assert(witnessFnTy->getRepresentation() ==
891892
SILFunctionTypeRepresentation::WitnessMethod);
@@ -901,9 +902,9 @@ getWitnessMethodSubstitutions(SILModule &Module, ApplySite AI, SILFunction *F,
901902
== CRef.getRequirement());
902903
auto *classWitness = witnessFnTy->getWitnessMethodClass(*mod);
903904

904-
return getWitnessMethodSubstitutions(
905-
mod, CRef, requirementSig, witnessThunkSig,
906-
origSubs, isDefaultWitness, classWitness);
905+
return ::getWitnessMethodSubstitutions(mod, CRef, requirementSig,
906+
witnessThunkSig, origSubs,
907+
isDefaultWitness, classWitness);
907908
}
908909

909910
/// Generate a new apply of a function_ref to replace an apply of a

0 commit comments

Comments
 (0)