Skip to content

FunctionSignatureOptimization: fix a miscompile in owned->guaranteed return value specialization #31581

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
merged 1 commit into from
May 8, 2020

Conversation

eeckstein
Copy link
Contributor

FSO can handle self-recursive calls.
But this only works if the result of the self-recursive call is actually returned and not used otherwise.
The check for this was missing.

https://bugs.swift.org/browse/SR-12677
rdar://problem/62895040

…return value specialization

FSO can handle self-recursive calls.
But this only works if the result of the self-recursive call is actually returned and not used otherwise.
The check for this was missing.

https://bugs.swift.org/browse/SR-12677
rdar://problem/62895040
@eeckstein eeckstein requested a review from gottesmm May 6, 2020 12:22
@eeckstein
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented May 6, 2020

Build failed
Swift Test OS X Platform
Git Sha - 36c6fe7

@eeckstein
Copy link
Contributor Author

@swift-ci test macOS

@gottesmm
Copy link
Contributor

gottesmm commented May 7, 2020

Looking at this now. Some of this code is interesting.

@eeckstein are you sure we don't need to do the same thing on line 172? I am still digesting the code (I haven't read it in a while).

@gottesmm
Copy link
Contributor

gottesmm commented May 7, 2020

@eeckstein nm. I looked in more detail.

@eeckstein
Copy link
Contributor Author

@gottesmm line 172 is just a conservative bail-out check. So I don't think we need this for functional correctness here

@@ -180,7 +180,7 @@ bb3:
}

// CHECK-LABEL: START: epilogue_retains_in_diamond_top_and_left_split_block
// CHECK: apply
// CHECK-NOT: apply
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add in a follow on commit a test to this file of this form that still has the old behavior if we don't currently have a test. I didn't check.

if (auto *AI = dyn_cast<ApplyInst>(II))
if (AI->getCalleeFunction() == II->getParent()->getParent())
return true;
if (auto *AI = dyn_cast<ApplyInst>(II)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM. Can you in a follow on commit add a comment here reminding the user that arg is going to be a return value of the function since we are performing retain motion. I was confused at first b/c of getArg.

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