diff --git a/include/swift/SIL/SILTypeProperties.h b/include/swift/SIL/SILTypeProperties.h index 28872711fecc..a97871fbbda9 100644 --- a/include/swift/SIL/SILTypeProperties.h +++ b/include/swift/SIL/SILTypeProperties.h @@ -262,6 +262,7 @@ class SILTypeProperties { return MayHaveCustomDeinit_t((Flags & CustomDeinitFlag) != 0); } + void setTrivial() { Flags &= ~NonTrivialFlag; } void setNonTrivial() { Flags |= NonTrivialFlag; } void setIsOrContainsRawPointer() { Flags |= HasRawPointerFlag; } diff --git a/lib/SIL/IR/TypeLowering.cpp b/lib/SIL/IR/TypeLowering.cpp index ffeb8a2fb92c..5a125b621652 100644 --- a/lib/SIL/IR/TypeLowering.cpp +++ b/lib/SIL/IR/TypeLowering.cpp @@ -775,8 +775,14 @@ namespace { type, getReferenceSILTypeProperties(isSensitive)); } } - return asImpl().handleAddressOnly( - type, getOpaqueSILTypeProperties(isSensitive)); + auto props = getOpaqueSILTypeProperties(isSensitive); + if (ProtocolDecl *bitwiseCopyable = + TC.Context.getProtocol(KnownProtocolKind::BitwiseCopyable)) { + // Archetypes only have unconditional conformance. + if (lookupConformance(type, bitwiseCopyable)) + props.setTrivial(); + } + return asImpl().handleAddressOnly(type, props); } RetTy visitExistentialType(CanType type,