Skip to content

Commit cc8af17

Browse files
Merge pull request #75404 from nate-chandler/rdar131960619
[MoveOnlyAddressChecker] Exclusivity handles DeadEnds.
2 parents 111bc46 + 3eb288f commit cc8af17

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,8 @@ struct MoveOnlyAddressCheckerPImpl {
14771477
/// Information about destroys that we use when inserting destroys.
14781478
ConsumeInfo consumes;
14791479

1480+
DeadEndBlocksAnalysis *deba;
1481+
14801482
/// PostOrderAnalysis used by the BorrowToDestructureTransform.
14811483
PostOrderAnalysis *poa;
14821484

@@ -1486,10 +1488,11 @@ struct MoveOnlyAddressCheckerPImpl {
14861488
MoveOnlyAddressCheckerPImpl(
14871489
SILFunction *fn, DiagnosticEmitter &diagnosticEmitter,
14881490
DominanceInfo *domTree, PostOrderAnalysis *poa,
1491+
DeadEndBlocksAnalysis *deba,
14891492
borrowtodestructure::IntervalMapAllocator &allocator)
14901493
: fn(fn), deleter(), canonicalizer(fn, domTree, deleter),
14911494
addressUseState(domTree), diagnosticEmitter(diagnosticEmitter),
1492-
poa(poa), allocator(allocator) {
1495+
deba(deba), poa(poa), allocator(allocator) {
14931496
deleter.setCallbacks(std::move(
14941497
InstModCallbacks().onDelete([&](SILInstruction *instToDelete) {
14951498
if (auto *mvi =
@@ -2049,7 +2052,9 @@ struct GatherUsesVisitor : public TransitiveAddressWalker<GatherUsesVisitor> {
20492052
liveness->initializeDef(bai);
20502053
liveness->computeSimple();
20512054
for (auto *consumingUse : li->getConsumingUses()) {
2052-
if (!liveness->isWithinBoundary(consumingUse->getUser())) {
2055+
if (!liveness->areUsesWithinBoundary(
2056+
{consumingUse},
2057+
moveChecker.deba->get(consumingUse->getFunction()))) {
20532058
diagnosticEmitter.emitAddressExclusivityHazardDiagnostic(
20542059
markedValue, consumingUse->getUser());
20552060
emittedError = true;
@@ -3981,7 +3986,7 @@ bool MoveOnlyAddressChecker::check(
39813986
assert(moveIntroducersToProcess.size() &&
39823987
"Must have checks to process to call this function");
39833988
MoveOnlyAddressCheckerPImpl pimpl(fn, diagnosticEmitter, domTree, poa,
3984-
allocator);
3989+
deadEndBlocksAnalysis, allocator);
39853990

39863991
#ifndef NDEBUG
39873992
static uint64_t numProcessed = 0;

test/SILOptimizer/moveonly_addresschecker.swift

+11
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,14 @@ func testAssertLikeUseDifferentBits() {
3535
}
3636
}
3737
}
38+
39+
// issue #75312
40+
struct S
41+
{
42+
@usableFromInline
43+
init(utf8:consuming [UInt8])
44+
{
45+
utf8.withUnsafeBufferPointer { _ in }
46+
fatalError()
47+
}
48+
}

0 commit comments

Comments
 (0)