Skip to content

[sil-combine] Fix a bug in the convert_function peephole #12162

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

swiftix
Copy link
Contributor

@swiftix swiftix commented Sep 28, 2017

Bail if the return type of the converted function is different from the
return type of the apply instruction.

Fixes rdar://problem/34603304

Bail if the return type of the converted function is different from the
return type of the apply instruction.

Fixes rdar://problem/34603304
// Bail if the result type of the converted callee is different from the callee's
// result type of the apply instruction.
if (SubstCalleeTy->getAllResultsType() != ConvertCalleeTy->getAllResultsType()) {
return nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

When parameter types don't match you emit an unchecked ref cast, you could do the same for the return value too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may result in introducing new BBs for the try_apply. And we don't want to generate new BBs in sil-combine.

@@ -417,6 +417,12 @@ SILCombiner::optimizeApplyOfConvertFunctionInst(FullApplySite AI,
if (SubstCalleeTy->hasArchetype() || ConvertCalleeTy->hasArchetype())
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this restriction is completely unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May be, but this is not the part of this bug-fix patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please try removing it in another patch and see what breaks :-)

@swiftix
Copy link
Contributor Author

swiftix commented Sep 28, 2017

@swift-ci please test

@tkremenek tkremenek merged commit 7233800 into swiftlang:swift-4.0-branch Sep 28, 2017
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