[AutoDiff] Diagnose unsupported coroutine differentiation. (#28921)
Coroutines are functions that can yield values and suspend/resume execution.
SIL has dedicated coroutine types. Coroutines are applied via `begin_apply`.
`read` and `modify` accessors are coroutines.
Coroutine differentiation requires extra support, so it should be diagnosed
for now.
Differentiation transform:
- Generalize differentiation utilities from `ApplyInst` to `FullApplySite`.
- `bool isArrayLiteralIntrinsic(FullApplySite)`
- `void forEachApplyDirectResult(FullApplySite, llvm::function_ref<...>)`
- `apply`: direct result is the `apply` result, unless the `apply` result
has tuple-type and a single `destructure_tuple` user. Then, direct results
are the `destructure_tuple` results.
- `begin_apply`: direct results are the `begin_apply` results.
- `try_apply`: direct results are successor blocks' arguments.
- `bool LinearMapInfo::shouldDifferentiateApplySite(FullApplySite)`
- Generalize activity analysis from `ApplyInst` to `FullApplySite`.
- Propagate variedness for `FullApplySite` through direct/indirect results and
`inout` arguments.
- Propagate usefulness for `FullApplySite` through arguments.
- Diagnose `begin_apply` instructions with active arguments and results in
`PullbackEmitter::visitBeginApplyInst`.
Sema:
- Diagnose `@differentiable` attribute on `read` and `modify` coroutines.
Resolves TF-1081.
TF-1080 tracks coroutine differentiation support.
TF-1083 tracks throwing function differentiation support.