Function gen_enzyme_body

Source
fn gen_enzyme_body(
    ecx: &ExtCtxt<'_>,
    x: &AutoDiffAttrs,
    n_active: u32,
    sig: &FnSig,
    d_sig: &FnSig,
    primal: Ident,
    new_names: &[String],
    span: Span,
    sig_span: Span,
    idents: Vec<Ident>,
    errored: bool,
) -> P<Block>
Expand description

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.