Closed
Description
Consider the testcase from #65073
Now we compile it down to:
..
// function_ref closure #1 in f(array:)
%7 = function_ref @$s6arrupd1f5arraySdSaySdG_tFySdzcfU_ : $@convention(thin) (@inout Double) -> () // user: %10
// function_ref forward-mode derivative of closure #1 in f(array:)
%8 = function_ref @$s6arrupd1f5arraySdSaySdG_tFySdzcfU_TJfSpSr : $@convention(thin) (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () // user: %11
// function_ref reverse-mode derivative of closure #1 in f(array:)
%9 = function_ref @$s6arrupd1f5arraySdSaySdG_tFySdzcfU_TJrSpSr : $@convention(thin) (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () // user: %12
%10 = thin_to_thick_function %7 : $@convention(thin) (@inout Double) -> () to $@noescape @callee_guaranteed (@inout Double) -> () // user: %13
%11 = thin_to_thick_function %8 : $@convention(thin) (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () to $@noescape @callee_guaranteed (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () // user: %14
%12 = thin_to_thick_function %9 : $@convention(thin) (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () to $@noescape @callee_guaranteed (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () // user: %15
%13 = convert_function %10 : $@noescape @callee_guaranteed (@inout Double) -> () to $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> // user: %16
%14 = convert_function %11 : $@noescape @callee_guaranteed (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () to $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> (@owned @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <τ_0_0.TangentVector>) for <Double> // user: %16
%15 = convert_function %12 : $@noescape @callee_guaranteed (@inout Double) -> @owned @callee_guaranteed (@inout Double) -> () to $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> (@owned @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <τ_0_0.TangentVector>) for <Double> // user: %16
%16 = differentiable_function [parameters 0] [results 0] %13 : $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double> with_derivative {%14 : $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> (@owned @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <τ_0_0.TangentVector>) for <Double>, %15 : $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> (@owned @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <τ_0_0.TangentVector>) for <Double>} // users: %95, %18
...
%95 = apply %16(%94) : $@differentiable(reverse) @noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0) -> () for <Double>
Note that we can fold differentiable_function
here enabling further simplifications and inlining of $s6arrupd1f5arraySdSaySdG_tFySdzcfU_