The Enzyme team has been doing something like that (AD at the LLVM step making it available to all LLVM languages) with Rust:
- https://internals.rust-lang.org/t/automatic-differentiation-...
- https://internals.rust-lang.org/t/automatic-differentiation-...
I've always thought that AD needs something akin to a "compile" step.