Skip to content
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

[SILGen] Fix a crash when a closure is converted to a block returning a value indirectly #73520

Merged
merged 3 commits into from
May 24, 2024

Conversation

ahatanaka
Copy link
Contributor

Fix the type of the function argument added to the entry basic block.

rdar://127745392

a value indirectly

Fix the type of the function argument added to the entry basic block.

rdar://127745392
@ahatanaka
Copy link
Contributor Author

@swift-ci please test

@ahatanaka
Copy link
Contributor Author

@swift-ci please test macOS

@ahatanaka ahatanaka marked this pull request as ready for review May 9, 2024 13:56
@egorzhdan egorzhdan requested a review from beccadax May 9, 2024 15:16
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label May 9, 2024
Copy link
Collaborator

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

This looks reasonable, however, I'm not an expert in this logic

@ahatanaka ahatanaka requested a review from rjmccall May 9, 2024 15:52
@ahatanaka
Copy link
Contributor Author

There's a bug (assertion failure) in IRGen, which I found just now.

@ahatanaka
Copy link
Contributor Author

@swift-ci please test

@ahatanaka
Copy link
Contributor Author

@swift-ci please test

@ahatanaka ahatanaka requested a review from DougGregor May 10, 2024 17:38
@@ -392,7 +392,8 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
if (blockTy->getNumResults() != 0) {
auto result = blockTy->getSingleResult();
if (result.getConvention() == ResultConvention::Indirect) {
indirectResult = entry->createFunctionArgument(blockResultTy);
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 doesn't seem to make any difference, but I wonder whether blockConv.getSingleSILResultType(SGF.getTypeExpansionContext())) should be passed instead of blockResultTy.getAddressType() to createFunctionArgument.

Copy link
Member

Choose a reason for hiding this comment

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

I think what you've got is right.

@@ -392,7 +392,8 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
if (blockTy->getNumResults() != 0) {
auto result = blockTy->getSingleResult();
if (result.getConvention() == ResultConvention::Indirect) {
indirectResult = entry->createFunctionArgument(blockResultTy);
Copy link
Member

Choose a reason for hiding this comment

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

I think what you've got is right.

@ahatanaka ahatanaka merged commit b5cc561 into main May 24, 2024
5 checks passed
@ahatanaka ahatanaka deleted the closure-to-block-indirect-return branch May 24, 2024 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants