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

EscapeAnalysis: fix a bug which results in not detecting an escape through an unowned reference. #40325

Merged
merged 1 commit into from
Nov 30, 2021

Conversation

eeckstein
Copy link
Contributor

ref_to_unowned and similar instructions must be checked if the operand/result types are treated as "pointers" in escape analysis.
Fixes a miscompile.

https://bugs.swift.org/browse/SR-15527
rdar://85772200

…ough an unowned reference.

`ref_to_unowned`  and similar instructions must be checked if the operand/result types are treated as "pointers" in escape analysis.
Fixes a miscompile.

https://bugs.swift.org/browse/SR-15527
rdar://85772200
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein changed the title EscapeAnalysis: fix a bug with results in not detecting an escape through an unowned reference. EscapeAnalysis: fix a bug which results in not detecting an escape through an unowned reference. Nov 30, 2021
Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Too bad this wasn't caught with a simple assert. This fix is good. I had to debug it myself to understand the problem though.

Why do you bailout on unchecked_conditional_cast? SIL.rst says "representation or ownership changes are unsupported". So if the cast changes reference-ness, then there's a bigger problem.

@eeckstein
Copy link
Contributor Author

Why do you bailout on unchecked_conditional_cast?

Just to be on the safe side. It doesn't harm.

@atrick
Copy link
Contributor

atrick commented Nov 30, 2021

Why do you bailout on unchecked_conditional_cast?

Just to be on the safe side. It doesn't harm.

At the very least, it means that we can't tell that a cast reference points to a local/unique object. I assume that's quite common and something we don't want to affect optimization. It could just be an assert instead of bailout.

Never mind, this only bails out in the rare case, so the PR is good as-is!

@eeckstein eeckstein merged commit 19f95eb into swiftlang:main Nov 30, 2021
@eeckstein eeckstein deleted the fix-escape-analysis branch November 30, 2021 20:58
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.

None yet

2 participants