Commits

Chris Lattner committed d196abc8a4d
When binding address-only let declarations to let arguments, use the buffer being passed in, instead of creating a temporary one and copying into it. For: func generic_identity<T>(let a : T) -> T { return a } We now get: sil @_TF2t216generic_identityU__FT1aQ__Q_ : $@thin <$T_0_0> (@out $T_0_0, @in $T_0_0) -> () { bb0(%0 : $*T, %1 : $*T): copy_addr [take] %1 to [initialization] %0 : $*T // id: %2 %3 = tuple () // user: %4 return %3 : $() // id: %4 } We used to produce: sil @_TF2t216generic_identityU__FT1aQ__Q_ : $@thin <$T_0_0> (@out $T_0_0, @in $T_0_0) -> () { bb0(%0 : $*T, %1 : $*T): %2 = alloc_box $T // let a // users: %5, %4, %3 copy_addr [take] %1 to [initialization] %2#1 : $*T // id: %3 copy_addr %2#1 to [initialization] %0 : $*T // id: %4 strong_release %2#0 : $Builtin.ObjectPointer // id: %5 %6 = tuple () // user: %7 return %6 : $() // id: %7 } and then optimize it into: sil @_TF2t216generic_identityU__FT1aQ__Q_ : $@thin <$T_0_0> (@out $T_0_0, @in $T_0_0) -> () { bb0(%0 : $*T, %1 : $*T): %2 = alloc_stack $T // let a // users: %5, %3, %4 copy_addr [take] %1 to [initialization] %2#1 : $*T // id: %3 copy_addr [take] %2#1 to [initialization] %0 : $*T // id: %4 dealloc_stack %2#0 : $*@local_storage T // id: %5 %6 = tuple () // user: %7 return %6 : $() // id: %7 } Swift SVN r11941