google / swift

The Swift Programming Language
https://swift.org/
840 stars 66 forks source link

[AutoDiff] Disable `differentiable_function_extract` explicit type assertion. #270

Closed dan-zheng closed 3 years ago

dan-zheng commented 3 years ago

Cherry-pick of https://github.com/apple/swift/pull/35239 during the holiday freeze.


differentiability_function_extract instruction has an optional explicit extractee type. This is currently used by TypeSubstCloner and the LoadableByAddress transform to rewrite differentiability_function_extract instructions while preserving @differentiable function type invariants.

There is an assertion that differentiability_function_extract instructions do not have explicit extractee types outside of canonical/lowered SIL. However, this does not handle the SIL deserialization case above: when a function containing a differentiable_function_extract instruction with an explicit type is deserialized into a raw SIL module (which happens when optimizations are enabled).

Removing the assertion unblocks this encountered use case.

Resolves SR-14004.

dan-zheng commented 3 years ago

Locally tested, merging to unblock progress. Happy to address any follow-up issues!