Commits

Chris Lattner committed 5425835c790
Rework handling of retain and release instructions in init methods of classes to track the release as something that needs the class reference to be alive at. This implements the first piece of that: if all elements of the class are uninitialized at the time of the release, just turn the release into a dealloc_ref. This is correct because we know that the value would have had to be fully initialized at a retain, and though careful construction, this only triggers in the init case. This allows us to compile this: class RootClassWithNontrivialStoredProperties { let x, y: SomeClass init?(failBeforeInitialization: ()) { return nil } } into: sil @_TFC1t39RootClassWithNontrivialStoredPropertiesCfMS0_FT24failBeforeInitializationT__GSqS0__ : $@thin (@thick RootClassWithNontrivialStoredProperties.Type) -> @owned Optional<RootClassWithNontrivialStoredProperties> { bb0(%0 : $@thick RootClassWithNontrivialStoredProperties.Type): %1 = alloc_ref $RootClassWithNontrivialStoredProperties // user: %2 dealloc_ref %1 : $RootClassWithNontrivialStoredProperties // id: %2 %3 = enum $Optional<RootClassWithNontrivialStoredProperties>, #Optional.None!enumelt // user: %4 return %3 : $Optional<RootClassWithNontrivialStoredProperties> // id: %4 } Swift SVN r21620