Commits
Chris Lattner committed b13719be220
reapply r12727 (passing an SGFContext down to emitGetAccessor from
emitRValueForDecl when we have it), now with a testcase. We formerly
compiled this:
protocol P {}
var lp : P { get: }
func f() -> P {
return lp
}
into:
sil @_TF3let1fFT_PS_1P_ : $@thin (@out P) -> () {
bb0(%0 : $*P):
// function_ref let.lp.getter : let.P
%1 = function_ref @_TF3letg2lpPS_1P_ : $@thin (@out P) -> () // user: %3
%2 = alloc_stack $P // users: %5, %4, %3
%3 = apply %1(%2#1) : $@thin (@out P) -> ()
copy_addr [take] %2#1 to [initialization] %0 : $*P // id: %4
dealloc_stack %2#0 : $*@local_storage P // id: %5
%6 = tuple () // user: %7
return %6 : $() // id: %7
}
we now avoid the copy:
sil @_TF3let1fFT_PS_1P_ : $@thin (@out P) -> () {
bb0(%0 : $*P):
// function_ref let.lp.getter : let.P
%1 = function_ref @_TF3letg2lpPS_1P_ : $@thin (@out P) -> () // user: %2
%2 = apply %1(%0) : $@thin (@out P) -> ()
%3 = tuple () // user: %4
return %3 : $() // id: %4
}
Swift SVN r12748