Skip to content

[5.9][move-only] Fix lazily initialized global initializers. #67380

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
Jul 19, 2023

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Jul 18, 2023

• Description: Without this, we emit a copy of noncopyable type error since we do not insert a mark_must_check on lazily initialized global initializers.

The language impact is that without this when we write code like the following we emit a copyable of noncopyable type error since the checker does not actually run on the lazily initialized globals.

var m1 = M4("1")
var m2 = M4("1")
struct Doit {
   static var m3 = M4("1")
   static var m4 = M4("1")
   static func run() {
       rewriteTwo(&m.s1, &m2.s2)
       rewriteTwo(&m3.s1, &m4.s2)
   }
}

• Risk: Very low. The fix involves us inserting a mark_must_check on a specific code pattern that did not have a mark_must_check inserted. So this should only involve noncopyable types and further only when this very specific code pattern is emitted by SILGen. The fix is very localized.
• Original PR: #67354
• Reviewed By: @jckarter @atrick
• Testing: Added Swift and SIL tests
• Resolves: rdar://111402912

Without this, we emit a copy of noncopyable type error since we do not insert a
mark_must_check on lazily initialized global initializers.

rdar://111402912
(cherry picked from commit 1f22f92)
@gottesmm gottesmm changed the title [move-only] Fix lazily initialized global initializers. [5.9][move-only] Fix lazily initialized global initializers. Jul 18, 2023
@gottesmm gottesmm marked this pull request as ready for review July 18, 2023 23:40
@gottesmm gottesmm requested a review from a team as a code owner July 18, 2023 23:40
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

#67354

@gottesmm gottesmm merged commit 1ee93f7 into swiftlang:release/5.9 Jul 19, 2023
@gottesmm gottesmm deleted the release-5.9-111402912 branch July 19, 2023 20:36
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