Skip to content

Commit 8e0a389

Browse files
Merge pull request #81574 from nate-chandler/cherrypick/release/6.2/rdar151325025
6.2: [MoveOnlyChecker] Don't complete phis.
2 parents 810fbce + f648171 commit 8e0a389

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ void MoveOnlyChecker::checkObjects() {
122122

123123
void MoveOnlyChecker::completeObjectLifetimes(
124124
ArrayRef<MarkUnresolvedNonCopyableValueInst *> insts) {
125-
// TODO: Delete once OSSALifetimeCompletion is run as part of SILGenCleanup.
126-
OSSALifetimeCompletion completion(fn, domTree, *deba->get(fn));
127-
128-
// Collect all values derived from each mark_unresolved_non_copyable_value
129-
// instruction via ownership instructions and phis.
130-
ValueWorklist transitiveValues(fn);
131-
for (auto *inst : insts) {
132-
transitiveValues.push(inst);
125+
// TODO: Delete once OSSALifetimeCompletion is run as part of SILGenCleanup.
126+
OSSALifetimeCompletion completion(fn, domTree, *deba->get(fn));
127+
128+
// Collect all values derived from each mark_unresolved_non_copyable_value
129+
// instruction via ownership instructions and phis.
130+
ValueWorklist transitiveValues(fn);
131+
for (auto *inst : insts) {
132+
transitiveValues.push(inst);
133133
}
134134
while (auto value = transitiveValues.pop()) {
135135
for (auto *use : value->getUses()) {
@@ -163,6 +163,10 @@ for (auto *inst : insts) {
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 @@ for (auto *inst : insts) {
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)