Skip to content

Commit da03910

Browse files
committed
[MoveOnlyAddressChecker] Exclusivity handles DEs.
Switch to the areUsesWithinBoundary API which takes dead-ends into account. rdar://131960619
1 parent e6aae02 commit da03910

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,8 @@ struct MoveOnlyAddressCheckerPImpl {
14731473
/// Information about destroys that we use when inserting destroys.
14741474
ConsumeInfo consumes;
14751475

1476+
DeadEndBlocksAnalysis *deba;
1477+
14761478
/// PostOrderAnalysis used by the BorrowToDestructureTransform.
14771479
PostOrderAnalysis *poa;
14781480

@@ -1482,10 +1484,11 @@ struct MoveOnlyAddressCheckerPImpl {
14821484
MoveOnlyAddressCheckerPImpl(
14831485
SILFunction *fn, DiagnosticEmitter &diagnosticEmitter,
14841486
DominanceInfo *domTree, PostOrderAnalysis *poa,
1487+
DeadEndBlocksAnalysis *deba,
14851488
borrowtodestructure::IntervalMapAllocator &allocator)
14861489
: fn(fn), deleter(), canonicalizer(fn, domTree, deleter),
14871490
addressUseState(domTree), diagnosticEmitter(diagnosticEmitter),
1488-
poa(poa), allocator(allocator) {
1491+
deba(deba), poa(poa), allocator(allocator) {
14891492
deleter.setCallbacks(std::move(
14901493
InstModCallbacks().onDelete([&](SILInstruction *instToDelete) {
14911494
if (auto *mvi =
@@ -2045,7 +2048,9 @@ struct GatherUsesVisitor : public TransitiveAddressWalker<GatherUsesVisitor> {
20452048
liveness->initializeDef(bai);
20462049
liveness->computeSimple();
20472050
for (auto *consumingUse : li->getConsumingUses()) {
2048-
if (!liveness->isWithinBoundary(consumingUse->getUser())) {
2051+
if (!liveness->areUsesWithinBoundary(
2052+
{consumingUse},
2053+
moveChecker.deba->get(consumingUse->getFunction()))) {
20492054
diagnosticEmitter.emitAddressExclusivityHazardDiagnostic(
20502055
markedValue, consumingUse->getUser());
20512056
emittedError = true;
@@ -3976,7 +3981,7 @@ bool MoveOnlyAddressChecker::check(
39763981
assert(moveIntroducersToProcess.size() &&
39773982
"Must have checks to process to call this function");
39783983
MoveOnlyAddressCheckerPImpl pimpl(fn, diagnosticEmitter, domTree, poa,
3979-
allocator);
3984+
deadEndBlocksAnalysis, allocator);
39803985

39813986
#ifndef NDEBUG
39823987
static uint64_t numProcessed = 0;

test/SILOptimizer/moveonly_addresschecker.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,14 @@ func testAssertLikeUseDifferentBits() {
3737
}
3838
}
3939
}
40+
41+
// issue #75312
42+
struct S
43+
{
44+
@usableFromInline
45+
init(utf8:consuming [UInt8])
46+
{
47+
utf8.withUnsafeBufferPointer { _ in }
48+
fatalError()
49+
}
50+
}

0 commit comments

Comments
 (0)