Skip to content

[AutoDiff] SILGen derivative function thunks must not be transparent. #27752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dan-zheng
Copy link
Contributor

SILGen generates thunks for derivative functions registered via
@differentiable and @differentiating attributes.

The thunks have a canonical, consistent naming (currently based on
the original function name and parameter indices) that TBDGen can also
generate via SILDeclRef::mangle.

These SILGen derivative function thunks must not be transparent; otherwise,
the functions will be inlined during MandatoryInlining and will not be
exposed publicly.

This bug was discovered as a DeadFunctionElimination crash:
function_ref instructions referencing transparent derivative thunks
had their referenced functions set to null by MandatoryInling and became
invalid.


More SILGen derivative function thunking documentation coming soon.

SILGen generates thunks for derivative functions registered via
`@differentiable` and `@differentiating` attributes.

The thunks have a canonical, consistent naming (currently based on
the original function name and parameter indices) that TBDGen can also
generate via `SILDeclRef::mangle`.

These SILGen derivative function thunks must not be transparent; otherwise,
the functions will be inlined during MandatoryInlining and will not be
exposed publicly.

This bug was discovered as a DeadFunctionElimination crash:
`function_ref` instructions referencing transparent derivative thunks
had their referenced functions set to null by MandatoryInling and became
invalid.
@dan-zheng dan-zheng added the tensorflow This is for "tensorflow" branch PRs. label Oct 17, 2019
@dan-zheng dan-zheng requested review from rxwei and marcrasi October 17, 2019 09:40
TBDGen behavior is not expected to change, testing in case.
@dan-zheng dan-zheng force-pushed the autodiff-thunk-must-not-transparent branch from f337af9 to 1e6bfbd Compare October 17, 2019 10:03
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@dan-zheng dan-zheng merged commit 7c384f8 into swiftlang:tensorflow Oct 17, 2019
@dan-zheng dan-zheng deleted the autodiff-thunk-must-not-transparent branch October 17, 2019 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tensorflow This is for "tensorflow" branch PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants