Skip to content

Commit 2e86916

Browse files
committed
[IRGen] Always use BitwiseCopyable TypeInfo.
If an archetype conforms to the protocol, use the new TypeInfo. This allows clients to use code in the stdlib that's built with BitwiseCopyable.
1 parent f0594a4 commit 2e86916

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/IRGen/GenArchetype.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,14 @@ const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) {
433433
: IsNotABIAccessible;
434434
}
435435

436-
auto &ASTContext = IGM.getSwiftModule()->getASTContext();
437-
if (ASTContext.LangOpts.hasFeature(Feature::BitwiseCopyable)) {
438-
// TODO: Should this conformance imply isAddressOnlyTrivial is true?
439-
auto *proto = ASTContext.getProtocol(KnownProtocolKind::BitwiseCopyable);
440-
// It's possible for the protocol not to exist if the stdlib is built
441-
// no_asserts.
442-
if (proto && IGM.getSwiftModule()->lookupConformance(archetype, proto)) {
443-
return BitwiseCopyableArchetypeTypeInfo::create(storageType,
444-
abiAccessible);
445-
}
436+
// TODO: Should this conformance imply isAddressOnlyTrivial is true?
437+
auto *bitwiseCopyableProtocol =
438+
IGM.getSwiftModule()->getASTContext().getProtocol(
439+
KnownProtocolKind::BitwiseCopyable);
440+
// The protocol won't be present in swiftinterfaces from older SDKs.
441+
if (bitwiseCopyableProtocol && IGM.getSwiftModule()->lookupConformance(
442+
archetype, bitwiseCopyableProtocol)) {
443+
return BitwiseCopyableArchetypeTypeInfo::create(storageType, abiAccessible);
446444
}
447445

448446
return OpaqueArchetypeTypeInfo::create(storageType, abiAccessible);

0 commit comments

Comments
 (0)