Module llvm_enzyme

Source

Functionsยง

assure_mut_ref ๐Ÿ”’
expand ๐Ÿ”’
We expand the autodiff macro to generate a new placeholder function which passes type-checking and can be called by users. The function body of the placeholder function will later be replaced on LLVM-IR level, so the design of the body is less important and for now should just prevent early inlining and optimizations which alter the function signature. The exact signature of the generated function depends on the configuration provided by the user, but here is an example:
first_ident ๐Ÿ”’
from_ast ๐Ÿ”’
gen_enzyme_body ๐Ÿ”’
We only want this function to type-check, since we will replace the body later on llvm level. Using loop {} does not cover all return types anymore, so instead we manually build something that should pass the type checker. We also add a inline_asm line, as one more barrier for rustc to prevent inlining or const propagation. inline_asm will also triggers an Enzyme crash if due to another bug would ever try to accidentially differentiate this placeholder function body. Finally, we also add back_box usages of all input arguments, to prevent rustc from optimizing any arguments away.
gen_enzyme_decl ๐Ÿ”’
gen_primal_call ๐Ÿ”’
has_ret ๐Ÿ”’
init_body_helper ๐Ÿ”’
name ๐Ÿ”’
outer_normal_attr ๐Ÿ”’