SIL: support specialized witness_method instructions

In Embedded Swift, witness method lookup is done from specialized witness tables.
For this to work, the type of witness_method must be specialized as well.
Otherwise the method call would be done with wrong parameter conventions (indirect instead of direct).
This commit is contained in:
Erik Eckstein
2024-10-04 16:44:32 +02:00
parent 895eb2a5c6
commit 792dee2f5f
11 changed files with 54 additions and 32 deletions

View File

@@ -531,6 +531,7 @@ SerializedSILLoader *SILModule::getSILLoader() {
std::pair<SILFunction *, SILWitnessTable *>
SILModule::lookUpFunctionInWitnessTable(ProtocolConformanceRef C,
SILDeclRef Requirement,
bool lookupInSpecializedWitnessTable,
SILModule::LinkingMode linkingMode) {
if (!C.isConcrete())
return {nullptr, nullptr};
@@ -539,7 +540,12 @@ SILModule::lookUpFunctionInWitnessTable(ProtocolConformanceRef C,
SILLinkerVisitor linker(*this, linkingMode);
linker.processConformance(C);
}
SILWitnessTable *wt = lookUpWitnessTable(C.getConcrete()->getRootConformance());
ProtocolConformance *conf = C.getConcrete();
if (!isa<SpecializedProtocolConformance>(conf) || !lookupInSpecializedWitnessTable) {
conf = conf->getRootConformance();
}
SILWitnessTable *wt = lookUpWitnessTable(conf);
if (!wt) {
LLVM_DEBUG(llvm::dbgs() << " Failed speculative lookup of "