Skip to content

Commit 0f19b93

Browse files
committed
Fix TypeLowering: BitwiseCopyable archetypes are trivial
1 parent 30b207e commit 0f19b93

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/swift/SIL/SILTypeProperties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class SILTypeProperties {
262262
return MayHaveCustomDeinit_t((Flags & CustomDeinitFlag) != 0);
263263
}
264264

265+
void setTrivial() { Flags &= ~NonTrivialFlag; }
265266
void setNonTrivial() { Flags |= NonTrivialFlag; }
266267
void setIsOrContainsRawPointer() { Flags |= HasRawPointerFlag; }
267268

lib/SIL/IR/TypeLowering.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,14 @@ namespace {
775775
type, getReferenceSILTypeProperties(isSensitive));
776776
}
777777
}
778-
return asImpl().handleAddressOnly(
779-
type, getOpaqueSILTypeProperties(isSensitive));
778+
auto props = getOpaqueSILTypeProperties(isSensitive);
779+
if (ProtocolDecl *bitwiseCopyable =
780+
TC.Context.getProtocol(KnownProtocolKind::BitwiseCopyable)) {
781+
// Archetypes only have unconditional conformance.
782+
if (lookupConformance(type, bitwiseCopyable))
783+
props.setTrivial();
784+
}
785+
return asImpl().handleAddressOnly(type, props);
780786
}
781787

782788
RetTy visitExistentialType(CanType type,

0 commit comments

Comments
 (0)