Skip to content

[4.1] SIL: Fix zealous assert in verifier #14134

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

aschwaighofer
Copy link
Contributor

A materialize for set / write-back sequence is not really mutating the opened existential on an Rvalue existential.

rdar://36799163

  • Explanation: We generate a write back for a non-mutating set on an r-value. This write back looks like a mutation on an open_existenial that only allows immutable access. The verifier of open_existential instructions will look at the use and complain when this use really is safe. The patch disable verification in this case.

  • Scope: A fix that makes the SIL verifier not assert on a correct code pattern.

  • Risk: Low. This disables an invalid assertion.

  • Testing: A Swift CI test was added

A materialize for set / write-back sequence is not really mutating the opened existential

rdar://36799163
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

// Non-Mutating set pattern that allows a inout (that can't really
// write back.
if (auto *AI = dyn_cast<ApplyInst>(inst)) {
if (isa<PointerToThinFunctionInst>(AI->getCallee())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get it. What does the function representation have to do with consuming-or-mutating arguments? I think this warrants a little more explanation.

@aschwaighofer
Copy link
Contributor Author

The only producer of this instruction is SILGen when it generates a materialize for set.

@aschwaighofer
Copy link
Contributor Author

I will follow-up with an updated comment on the master branch.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a4238fa

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a4238fa

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a4238fa

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a4238fa

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - ac8cd1f

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ac8cd1f

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.

Approved for CCC.

@aschwaighofer
Copy link
Contributor Author

@swift-ci please nominate

@aschwaighofer aschwaighofer merged commit c171921 into swiftlang:swift-4.1-branch Jan 25, 2018
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