Skip to content

Commit f648171

Browse files
committed
[MoveOnlyChecker] Don't complete phis.
Apply the MoveOnlyAddressChecker change from #73358 to the MoveOnly[Value]Checker. After 7713eef, before running value checking, all lifetimes in the function are completed. That doesn't quite work because lifetime completion expects not to encounter reborrows or their adjacent phis. rdar://151325025
1 parent acb6c71 commit f648171

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ void MoveOnlyChecker::completeObjectLifetimes(
163163
for (auto *block : poa->get(fn)->getPostOrder()) {
164164
for (SILInstruction &inst : reverse(*block)) {
165165
for (auto result : inst.getResults()) {
166+
if (llvm::any_of(result->getUsers(),
167+
[](auto *user) { return isa<BranchInst>(user); })) {
168+
continue;
169+
}
166170
if (!transitiveValues.isVisited(result))
167171
continue;
168172
if (completion.completeOSSALifetime(
@@ -173,7 +177,9 @@ void MoveOnlyChecker::completeObjectLifetimes(
173177
}
174178
}
175179
for (SILArgument *arg : block->getArguments()) {
176-
assert(!arg->isReborrow() && "reborrows not legal at this SIL stage");
180+
if (arg->isReborrow()) {
181+
continue;
182+
}
177183
if (!transitiveValues.isVisited(arg))
178184
continue;
179185
if (completion.completeOSSALifetime(
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %target-build-swift %s
2+
3+
typealias LeagueDayOfWeek = UInt8
4+
5+
let settings = LeagueSettings(divisions: [.init(id: 0, dayOfWeek: 0), .init(id: 1, dayOfWeek: 0)])
6+
let dummy = Dummy()
7+
dummy.dummy(settings: settings)
8+
9+
struct LeagueSettings: Codable, Sendable {
10+
let divisions:ContiguousArray<LeagueDivision>
11+
}
12+
struct LeagueEntry: Codable, Sendable {
13+
typealias IDValue = Int
14+
}
15+
struct LeagueDivision: Codable, Hashable, Sendable {
16+
typealias IDValue = Int
17+
let id:IDValue
18+
let dayOfWeek:LeagueDayOfWeek
19+
}
20+
struct Dummy: ~Copyable {
21+
}
22+
extension Dummy {
23+
func dummy(settings: LeagueSettings) {
24+
var divisionEntries:ContiguousArray<Set<LeagueEntry.IDValue>> = .init(repeating: Set(), count: settings.divisions.count)
25+
var grouped:[LeagueDayOfWeek:Set<LeagueEntry.IDValue>] = [:]
26+
for division in settings.divisions {
27+
/* // OK
28+
if grouped[division.dayOfWeek] == nil {
29+
grouped[division.dayOfWeek] = divisionEntries[division.id]
30+
} else {
31+
grouped[division.dayOfWeek]!.formUnion(divisionEntries[division.id])
32+
}*/
33+
grouped[division.dayOfWeek, default: []].formUnion(divisionEntries[division.id]) // crashes
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)