Closed ZuseZ4 closed 4 months ago
compiler/rustc_builtin_macros/src/autodiff.rs -> this parses the user facing autodiff macro and creates the internal
rustc_autodiff attribute. This serves as a barrier s.t. only verified things are passed down to Enzyme.
the expand() function creates both the original and new function.
On the new (placeholder) function you would need to append one extra attribute, if you notice that the original function returns -> ().
The enum DiffActivity
itself is defined in compiler/rustc_ast/src/expand/autodiff_attrs.rs,
you would need to add a NoReturnValue activity or something in that style.
You might also need to adjust some of my checks there (e.g. valid_input_activity).
In compiler/rustc_codegen_ssa/src/codegen_attrs.rs we then read the rustc_attr, so there you can now add a new check to make sure that the new variant is used iff the primal function returns ().
If you have a chance, please extend https://enzyme.mit.edu/index.fcgi/rust/rustc_design.html along the way with issues you encounter.
@jedbrown fixed by 78bd09a
The last argument to the rustc_autodiff attribute is taken as return activity. I forgot to add a no_return placeholder to the activity enum and introduce it in the rustc_builtin_macro autodiff.rs parsing. cc @jedbrown