Skip to content

[6.2] Swift SIL: Fix argument conventions for functions which have both, a direct and indirect result. #81865

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

eeckstein
Copy link
Contributor

  • Explanation: This fixes a mis-compile with functions, which return a tuple where the first tuple element is a direct result and the second tuple element is an indirect result. This lets alias analysis assume that the memory pointed to by the indirect argument cannot be written by the called function.
  • Risk: Low. It's a simple fix which corrects the subscript operation of a LazyFilterCollection in the swift compiler sources.
  • Testing: Tested by lit tests.
  • Issue: rdar://152160748
  • Reviewer: @atrick
  • Main branch PR: Swift SIL: Fix argument conventions for functions which have both, a direct and indirect result #81806

…direct and indirect result.

The function convention for the first argument is not identified as indirect-out.
This lets alias analysis assume that the memory pointed to by argument 0 cannot be written by the called function.

The problem is that subscripting a LazyFilterCollection (with the base index, e.g. `Int`) does not work as expected, because it returns the nth element of the base collection!
The fix is to implement the subscript "manually".

Fixes a mis-compile.
rdar://152160748
@eeckstein eeckstein requested a review from a team as a code owner May 30, 2025 10:44
@eeckstein eeckstein requested a review from atrick May 30, 2025 10:44
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit 06f0913 into swiftlang:release/6.2 Jun 2, 2025
5 checks passed
@eeckstein eeckstein deleted the eeckstein-fix-argument-convention-6.2 branch June 2, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants