-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
[Autodiff upstream] Add DifferentiabilityWitnessDevirtualizer SILOptimizer pass #30984
Conversation
@dan-zheng What does #30969 mean for this? |
@swift-ci please smoke test |
@swift-ci please test |
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.
c3e65cc
to
c641df2
Compare
There was a problem hiding this 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.
// Devirtualizes `differentiability_witness_function` instructions into | ||
// `function_ref` instructions for differentiability witness definitions. |
There was a problem hiding this comment.
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.
@swift-ci Please test |
Build failed |
Build failed |
@gottesmm Do you have time to review or WWDC/branching gots you swamped? :) |
Let's merge this to make progress. I think the new optimization pass is not super controversial, rationale here. |
…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]>
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.