[AutoDiff] Support differentiation of side effects. (#22057)
* [AutoDiff] Support differentiation of side effects.
This patch adds support for differentiating through reads and writes from/to `var`s. Specifically, what made this possible is a set of differentiation rules for side-effecting operations: `alloc_stack`, `dealloc_stack`, `begin_access`, `end_access`, `load`, `store`, etc.
This patch also fixes the following minor bugs:
* When `AdjointEmitter::getAdjointValue` creates a default adjoint value, correctly remap the original type to get rid of archetypes.
* Handle more reference counting instructions.
* Emit better diagnostics for not being able to differentiate writes to global variables and to mutable captures.
Note:
* Temporarily allow memory leaks to unblock progress/fix tests.