[IRGen] Implement resilient access pattern for associated conformances.

When referencing an associated conformance in a witness table for a
resilient protocol, use the associated conformance descriptor to compute
the index into the witness table at run-time.

Another part of rdar://problem/44167982.
This commit is contained in:
Doug Gregor
2018-09-17 17:26:05 -07:00
parent 4549fcd673
commit 8a9df1ce34
5 changed files with 58 additions and 12 deletions

View File

@@ -3387,6 +3387,16 @@ llvm::GlobalValue *IRGenModule::defineAssociatedTypeDescriptor(
return defineAlias(entity, definition);
}
llvm::Constant *IRGenModule::getAddrOfAssociatedConformanceDescriptor(
AssociatedConformance conformance) {
auto entity = LinkEntity::forAssociatedConformanceDescriptor(
conformance.getSourceProtocol(),
conformance.getAssociation(),
conformance.getAssociatedRequirement());
return getAddrOfLLVMVariable(entity, getPointerAlignment(), ConstantInit(),
ProtocolRequirementStructTy, DebugTypeInfo());
}
llvm::GlobalValue *IRGenModule::defineAssociatedConformanceDescriptor(
ProtocolDecl *proto,
CanType subject,