@@ -48,16 +48,15 @@ fn get_params(fnc: &Value) -> Vec<&Value> {
4848 }
4949}
5050
51- // The lowering of one `#[autodiff]` macro happens in multiple steps.
52- // First we transalte generate a new dummy function, who's llvm-ir we now have as outer_fn.
53- // We kept track of the original function to which the `#[autodiff]` macro was applied to, which we
54- // now have as fn_to_diff. In our current implementation, we use the enzyme pass to carry out the
55- // differentiation, following naming and calling conventions documented here: <https://enzyme.mit.edu/getting_started/CallingConvention/>
56- //
57- // Our `outer_fn` had some dummy code inserted at higher levels, so we first remove most of the
58- // existing body. We then insert an `__enzyme_<autodiff/fwddiff>_<unique_id>` call, which the pass
59- // will then pick up. FIXME(ZuseZ4): We will later want to upstream safety checks to the `outer_fn`,
60- // in order to cover some assumptions of enzyme/autodiff, which could lead to UB otherwise.
51+ /// When differentiating `fn_to_diff`, take a `outer_fn` and generate another
52+ /// function with expected naming and calling conventions[^1] which will be
53+ /// discovered by the enzyme LLVM pass and its body populated with the differentiated
54+ /// `fn_to_diff`. `outer_fn` is then modified to have a call to the generated
55+ /// function and handle the differences between the Rust calling convention and
56+ /// Enzyme.
57+ /// [^1]: <https://enzyme.mit.edu/getting_started/CallingConvention/>
58+ // FIXME(ZuseZ4): `outer_fn` should include upstream safety checks to
59+ // cover some assumptions of enzyme/autodiff, which could lead to UB otherwise.
6160pub ( crate ) fn generate_enzyme_call < ' ll > (
6261 llmod : & ' ll llvm:: Module ,
6362 llcx : & ' ll llvm:: Context ,
0 commit comments