[Optimizer] Use OptimizationResult
rather than OptimizationState
in more places
#58116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a data-flow refactor that removes the need to carry
OptimizationState
around as much, especially duringfinish!
and inresult.src
for inlining. Instead, more fields have been defined forOptimizationResult
to hold the minimal amount of information needed to perform these possibly required transforms:compute_inlining_cost!
, relying on.inlining_cost::InlineCostType
and.rt::Any
.ir_to_codeinf!
, relying onsrc::CodeInfo
andcode_info::CodeInfo
. Strictly speaking, only one field is required asir_to_codeinf!(src, ir)
mutatessrc
in place, but I'd rather avoid ambiguity.With this in mind,
transform_result_for_local_cache
andtransform_result_for_cache
should now return anOptimizationResult
, andresult.src
should no longer be of typeOptimizationState
oncefinish!
returns.The next step (in a future PR unless it is deemed preferable to do it in this one) would be to try to replace the volatile inference mechanism introduced in #51934 with
OptimizationResult
by using its ability to holdIRCode
without requiring a round-trip toCodeInfo
upon retrieval for inlining passes.