Skip to content

Correct the region isolation rule for metatype extraction instructions #79408

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/SILOptimizer/Analysis/RegionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3002,6 +3002,8 @@ CONSTANT_TRANSLATION(IndexRawPointerInst, Assign)
CONSTANT_TRANSLATION(InitExistentialMetatypeInst, Assign)
CONSTANT_TRANSLATION(OpenExistentialMetatypeInst, Assign)
CONSTANT_TRANSLATION(ObjCToThickMetatypeInst, Assign)
CONSTANT_TRANSLATION(ValueMetatypeInst, Assign)
CONSTANT_TRANSLATION(ExistentialMetatypeInst, Assign)

// These are used by SIL to aggregate values together in a gep like way. We
// want to look at uses of structs, not the struct uses itself. So just
Expand Down Expand Up @@ -3124,10 +3126,6 @@ CONSTANT_TRANSLATION(UnmanagedAutoreleaseValueInst, Require)
CONSTANT_TRANSLATION(RebindMemoryInst, Require)
CONSTANT_TRANSLATION(BindMemoryInst, Require)
CONSTANT_TRANSLATION(BeginUnpairedAccessInst, Require)
// Require of the value we extract the metatype from.
CONSTANT_TRANSLATION(ValueMetatypeInst, Require)
// Require of the value we extract the metatype from.
CONSTANT_TRANSLATION(ExistentialMetatypeInst, Require)
// These can take a parameter. If it is non-Sendable, use a require.
CONSTANT_TRANSLATION(GetAsyncContinuationAddrInst, Require)

Expand Down
10 changes: 10 additions & 0 deletions test/Concurrency/sendable_metatype.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ nonisolated func passSendableToMainActorSmuggledAny<T: Sendable>(_: T.Type) asyn
let x: Sendable.Type = T.self
await acceptMetaOnMainActor(x)
}

// -------------------------------------------------------------------------
// Existential opening
// -------------------------------------------------------------------------
nonisolated func passMetaSmuggledAnyFromExistential(_ qT: Q.Type) {
let x: Any.Type = qT
Task.detached { // expected-error{{risks causing data races}}
acceptMeta(x) // expected-note{{closure captures 'x' which is accessible to code in the current task}}
}
}