Commits
Chris Lattner committed 8c916c31f4d
Fix <rdar://problem/19275047> Extraneous retains/releases of self are bad
This teaches SILGenLValue that base expressions referring to self can always
be done at +0, avoiding retain/release traffic. This eliminates some hacks
where init() needed special code, and also reduces r/r traffic in general.
Before the example in the radar silgen'd to:
sil hidden @_TFC1x4Base3foofS0_FT_T_ : $@cc(method) @thin (@owned Base) -> () {
bb0(%0 : $Base):
debug_value %0 : $Base // let self // id: %1
strong_retain %0 : $Base // id: %2
// function_ref x.Base.__allocating_init (x.Base.Type)() -> x.Base
%3 = function_ref @_TFC1x4BaseCfMS0_FT_S0_ : $@thin (@thick Base.Type) -> @owned Base // user: %5
%4 = metatype $@thick Base.Type // user: %5
%5 = apply %3(%4) : $@thin (@thick Base.Type) -> @owned Base // user: %7
%6 = ref_element_addr %0 : $Base, #Base.f // user: %7
assign %5 to %6 : $*Base // id: %7
strong_release %0 : $Base // id: %8
strong_release %0 : $Base // id: %9
%10 = tuple () // user: %11
return %10 : $() // id: %11
}
now the %2 and %8 instructions are gone.
Swift SVN r23977