Skip to content

[6.2][SILOptimizer]: fix some missing use after consume diagnostics #83525

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

Open
wants to merge 1 commit into
base: release/6.2
Choose a base branch
from

Conversation

jamieQ
Copy link
Contributor

@jamieQ jamieQ commented Aug 4, 2025

Explanation:
Updates ConsumeOperatorCopyableValuesChecker to identify store_borrow instructions as a liveness-affecting use so that patterns that would previously slip through undiagnosed are correctly identified

Scope:

  • addresses a regression with use-after-consume diagnostics
  • diagnostic pass handles more cases, so could plausibly break code that used to compile

Issues:

Original PRs:

Risk:

  • Low. The patch only affects consume-checking of copyable values. Furthermore, it only increases the strictness of that checking, so it shouldn't cause any previously diagnosed code to go undiagnosed.

Testing:

  • new unit tests added

Reviewers:

Updates ConsumeOperatorCopyableValuesChecker to identify store_borrow
instructions as a liveness-affecting use so that patterns that would
previously slip through undiagnosed are correctly identified. e.g.

```swift
func use<V>(_ v: borrowing V) {}

func f() {
  let a = A()
  _ = consume a
  use(a) // previously would not be diagnosed
}
```

(cherry picked from commit 754a300)
@jamieQ jamieQ requested a review from a team as a code owner August 4, 2025 17:40
@jamieQ
Copy link
Contributor Author

jamieQ commented Aug 4, 2025

@swift-ci please smoke test

@jamieQ
Copy link
Contributor Author

jamieQ commented Aug 4, 2025

@nate-chandler could you please let me know your assessment of the 'risk' of this change (and feel free to just edit the description if that's possible)?

@nate-chandler
Copy link
Contributor

@jamieQ certainly! This is a low risk change. It only affects consume checking of copyable values. It only increases the strictness of that checking, so it shouldn't cause any previously diagnosed code to go undiagnosed.

@jamieQ
Copy link
Contributor Author

jamieQ commented Aug 4, 2025

@DougGregor FYI as release manager

@jamieQ
Copy link
Contributor Author

jamieQ commented Aug 5, 2025

@swift-ci please test linux platform

@jamieQ
Copy link
Contributor Author

jamieQ commented Aug 5, 2025

@swift-ci please test macos platform

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.

2 participants