File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -738,8 +738,13 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) {
738738 // move only structs are non-trivial, so we need to handle this here.
739739 if (nominal->getAttrs ().hasAttribute <RawLayoutAttr>()) {
740740 // Raw memory is not directly decomposable, but we still want to mark
741- // it as initialized. Use a zero initializer.
742- B.createZeroInitAddr (ctor, selfLV.getLValueAddress ());
741+ // it as initialized.
742+ auto prepInit = getBuiltinValueDecl (getASTContext (),
743+ getASTContext ().getIdentifier (" prepareInitialization" ));
744+ B.createBuiltin (ctor, prepInit->getBaseIdentifier (),
745+ SILType::getEmptyTupleType (getASTContext ()),
746+ SubstitutionMap (),
747+ selfLV.getLValueAddress ());
743748 } else if (isa<StructDecl>(nominal)
744749 && lowering.getLoweredType ().isMoveOnly ()
745750 && nominal->getStoredProperties ().empty ()) {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ struct Lock: ~Copyable {
2020 // CHECK-NEXT: sil{{.*}} @[[INIT:\$.*4LockV.*fC]] :
2121 init ( ) {
2222 // CHECK-NOT: destroy_addr
23- // CHECK: builtin "zeroInitializer "({{%.*}} : $*Lock)
23+ // CHECK: builtin "prepareInitialization "({{%.*}} : $*Lock)
2424 // CHECK-NOT: destroy_addr
2525 // CHECK: [[F:%.*]] = function_ref @init_lock
2626 // CHECK: apply [[F]](
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public struct Cell<T: ~Copyable>: ~Copyable {
2020
2121 // CHECK-LABEL: sil {{.*}} @$s4CellAAVAARi_zrlEyAByxGxcfC : $@convention(method) <T where T : ~Copyable> (@in T, @thin Cell<T>.Type) -> @out Cell<T> {
2222 // CHECK: bb0({{%.*}} : $*Cell<T>, [[VALUE:%.*]] : $*T, {{%.*}} : $@thin Cell<T>.Type):
23- // CHECK: {{%.*}} = builtin "zeroInitializer "([[SELF:%.*]] : $*Cell<T>) : $()
23+ // CHECK: {{%.*}} = builtin "prepareInitialization "([[SELF:%.*]] : $*Cell<T>) : $()
2424 // CHECK-NEXT: [[RAW_LAYOUT_ADDR:%.*]] = builtin "addressOfRawLayout"<Cell<T>>([[SELF]] : $*Cell<T>) : $Builtin.RawPointer
2525 // CHECK-NEXT: [[POINTER:%.*]] = struct $UnsafeMutablePointer<T> ([[RAW_LAYOUT_ADDR]] : $Builtin.RawPointer)
2626 // Calling 'UnsafeMutablePointer<T>.initialize(to:)'
You can’t perform that action at this time.
0 commit comments