Skip to content

[cast-opt] Allow users to pass in a SILBuilderContext to the CastOpti… #22355

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

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Feb 4, 2019

…mizer.

NOTE: I changed all places that the CastOptimizer is created to just pass in
nullptr for now so this is NFC.


Right now the interface of the CastOptimizer is muddled and confused. Sometimes
it is returning a value that should be used by the caller, other times it is
returning an instruction that is meant to be reprocessed by the caller.

This series of patches is attempting to clean this up by switching to the
following model:

  1. If we are optimizing a cast of a value, we return a SILValue. If the cast
    fails, we return an empty SILValue().

  2. If we are optimizing a cast of an address, we return a boolean value to show
    success/failure and require the user to use the SILBuilderContext to get the
    cast if they need to.

…mizer.

NOTE: I changed all places that the CastOptimizer is created to just pass in
nullptr for now so this is NFC.

----

Right now the interface of the CastOptimizer is muddled and confused. Sometimes
it is returning a value that should be used by the caller, other times it is
returning an instruction that is meant to be reprocessed by the caller.

This series of patches is attempting to clean this up by switching to the
following model:

1. If we are optimizing a cast of a value, we return a SILValue. If the cast
fails, we return an empty SILValue().

2. If we are optimizing a cast of an address, we return a boolean value to show
success/failure and require the user to use the SILBuilderContext to get the
cast if they need to.
@gottesmm gottesmm requested a review from atrick February 4, 2019 21:00
@gottesmm
Copy link
Contributor Author

gottesmm commented Feb 4, 2019

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 4dabf9f into swiftlang:master Feb 4, 2019
@gottesmm gottesmm deleted the pr-da7a380ffb527032db33e17037611065c0430078 branch February 4, 2019 21:55
@atrick
Copy link
Contributor

atrick commented Feb 4, 2019

lgtm

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