Skip to content

[Autodiff upstream] Add DifferentiabilityWitnessDevirtualizer SILOptimizer pass #30984

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

Conversation

ematejska
Copy link
Contributor

Upstream an optimization pass that devirtualizes differentiability witnesses into functions that reference them, replacing differentiability_witness_functions with function_refs.

This resolves https://bugs.swift.org/browse/TF-1241.

@ematejska ematejska requested review from marcrasi and dan-zheng April 12, 2020 04:12
@ematejska
Copy link
Contributor Author

@dan-zheng What does #30969 mean for this?

@ematejska
Copy link
Contributor Author

@swift-ci please smoke test

@ematejska
Copy link
Contributor Author

@swift-ci please test

@dan-zheng
Copy link
Contributor

@dan-zheng What does #30969 mean for this?

No worries about code reorganization in #30969, that shouldn't block any work and should be done once we reach consensus with SILOptimizer code owners.

Fix file header comments.
@dan-zheng dan-zheng force-pushed the autodiff_upstream_DifferentiabilityWitnessDevirtualizer branch from c3e65cc to c641df2 Compare April 12, 2020 04:51
Copy link
Contributor

@dan-zheng dan-zheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I pushed a commit fixing minor typos in DifferentiabilityWitnessDevirtualizer.cpp, hope you don't mind.

Comment on lines +13 to +14
// Devirtualizes `differentiability_witness_function` instructions into
// `function_ref` instructions for differentiability witness definitions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some context on why DifferentiabilityWitnessDevirtualizer was created as a new transform instead of augmenting swift::tryDevirtualizeApply: #28480 (comment).

Given the similarity to the SIL devirtualizer, maybe it's easier to just add some logic in swift::tryDevirtualizeApply that handles DifferentiabilityWitnessFunction instructions.

Currently this would be pretty involved because the SIL devirtualizer starts at apply methods and looks for the callee. A lot of the callees in differentiation cases are hidden behind differentiable_function and differentiable_function_extracts.

The pass as written handles the devirtualization at the reference sites, avoiding this difficulty.

@dan-zheng dan-zheng requested a review from gottesmm April 12, 2020 04:55
@dan-zheng
Copy link
Contributor

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - fac70ef

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - fac70ef

@ematejska
Copy link
Contributor Author

@gottesmm Do you have time to review or WWDC/branching gots you swamped? :)

@dan-zheng
Copy link
Contributor

Let's merge this to make progress. I think the new optimization pass is not super controversial, rationale here.

@dan-zheng dan-zheng merged commit 4cd68ed into swiftlang:master Apr 23, 2020
@ematejska ematejska deleted the autodiff_upstream_DifferentiabilityWitnessDevirtualizer branch April 23, 2020 16:48
rxwei pushed a commit to rxwei/swift that referenced this pull request Jun 3, 2020
…mizer pass (swiftlang#30984)

Add DifferentiabilityWitnessDevirtualizer: an optimization pass that
devirtualizes `differentiability_witness_function` instructions into
`function_ref` instructions.

Co-authored-by: Dan Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants