IRGen: Use deinit to destroy move-only structs that have them.

The `deinit` takes full responsibility for destroying the value, using the
user-defined deinit body and implicitly destroying any remaining resources
not consumed during the deinit.

Remaining to do after this patch:

- Run the deinit for enums
- Pass generic arguments for generic move-only types
- Handle deinits that take their parameter indirectly
- Teach value witness layout about when types are move-only and/or have
  deinits, so that we don't attempt to give move-only types standard
  value witness tables or share box metadata with copyable payloads
This commit is contained in:
Joe Groff
2023-02-22 11:43:18 -08:00
parent 7018c5575e
commit afa5837aeb
14 changed files with 449 additions and 50 deletions

View File

@@ -449,7 +449,7 @@ IRGenModule::getOrCreateReleaseFunction(const TypeInfo &ti,
loadableTI->getFixedAlignment());
Explosion loaded;
loadableTI->loadAsTake(IGF, addr, loaded);
loadableTI->consume(IGF, loaded, atomicity);
loadableTI->consume(IGF, loaded, atomicity, t);
IGF.Builder.CreateRet(addr.getAddress());
},
true /*setIsNoInline*/);