Skip to content

Commit 5023b93

Browse files
committed
[move-only] Eliminate dead field.
Originally this was a method to determine if we had emitted a diagnostic when running our gather visitor. It was pretty footgunny since one could easily forget to set it. Instead of doing that, we now maintain a counter in the diagnostic emitter that counts how many diagnostics we have emitted and use that to determine if during the walk if we emitted any additional diagnostics. (cherry picked from commit d252902)
1 parent b5d7d70 commit 5023b93

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,6 @@ struct GatherUsesVisitor final : public TransitiveAddressWalker {
14411441
MoveOnlyAddressCheckerPImpl &moveChecker;
14421442
UseState &useState;
14431443
MarkMustCheckInst *markedValue;
1444-
bool emittedEarlyDiagnostic = false;
14451444
DiagnosticEmitter &diagnosticEmitter;
14461445

14471446
// Pruned liveness used to validate that load [take]/load [copy] can be
@@ -1616,14 +1615,13 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
16161615
if (isa<ProjectBoxInst>(stripAccessMarkers(markedValue->getOperand()))) {
16171616
LLVM_DEBUG(llvm::dbgs()
16181617
<< "Found mark must check [nocopy] use of escaping box: " << *user);
1619-
diagnosticEmitter.emitAddressEscapingClosureCaptureLoadedAndConsumed(markedValue);
1620-
emittedEarlyDiagnostic = true;
1618+
diagnosticEmitter.emitAddressEscapingClosureCaptureLoadedAndConsumed(
1619+
markedValue);
16211620
return true;
16221621
}
16231622
LLVM_DEBUG(llvm::dbgs()
16241623
<< "Found mark must check [nocopy] error: " << *user);
16251624
diagnosticEmitter.emitAddressDiagnosticNoCopy(markedValue, copyAddr);
1626-
emittedEarlyDiagnostic = true;
16271625
return true;
16281626
}
16291627

@@ -1679,15 +1677,13 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
16791677
.didEmitCheckerDoesntUnderstandDiagnostic());
16801678
LLVM_DEBUG(llvm::dbgs()
16811679
<< "Failed to perform borrow to destructure transform!\n");
1682-
emittedEarlyDiagnostic = true;
16831680
return false;
16841681
}
16851682

16861683
// If we emitted an error diagnostic, do not transform further and instead
16871684
// mark that we emitted an early diagnostic and return true.
16881685
if (numDiagnostics != moveChecker.diagnosticEmitter.getDiagnosticCount()) {
16891686
LLVM_DEBUG(llvm::dbgs() << "Emitting borrow to destructure error!\n");
1690-
emittedEarlyDiagnostic = true;
16911687
return true;
16921688
}
16931689

@@ -1708,7 +1704,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17081704
if (numDiagnostics != moveChecker.diagnosticEmitter.getDiagnosticCount()) {
17091705
LLVM_DEBUG(llvm::dbgs()
17101706
<< "Emitting destructure through deinit error!\n");
1711-
emittedEarlyDiagnostic = true;
17121707
return true;
17131708
}
17141709

@@ -1738,7 +1733,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17381733
moveChecker.diagnosticEmitter
17391734
.emitAddressEscapingClosureCaptureLoadedAndConsumed(markedValue);
17401735
}
1741-
emittedEarlyDiagnostic = true;
17421736
return true;
17431737
}
17441738

@@ -1752,7 +1746,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17521746

17531747
if (checkForExclusivityHazards(li)) {
17541748
LLVM_DEBUG(llvm::dbgs() << "Found exclusivity violation?!\n");
1755-
emittedEarlyDiagnostic = true;
17561749
return true;
17571750
}
17581751

@@ -1785,7 +1778,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17851778
// succeeded.
17861779
// Otherwise, emit the diagnostic.
17871780
moveChecker.diagnosticEmitter.emitObjectOwnedDiagnostic(markedValue);
1788-
emittedEarlyDiagnostic = true;
17891781
LLVM_DEBUG(llvm::dbgs() << "Emitted early object level diagnostic.\n");
17901782
return true;
17911783
}
@@ -1794,7 +1786,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17941786
LLVM_DEBUG(llvm::dbgs() << "Found potential borrow inst: " << *user);
17951787
if (checkForExclusivityHazards(li)) {
17961788
LLVM_DEBUG(llvm::dbgs() << "Found exclusivity violation?!\n");
1797-
emittedEarlyDiagnostic = true;
17981789
return true;
17991790
}
18001791

@@ -1843,7 +1834,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
18431834
moveChecker.diagnosticEmitter
18441835
.emitAddressEscapingClosureCaptureLoadedAndConsumed(markedValue);
18451836
}
1846-
emittedEarlyDiagnostic = true;
18471837
return true;
18481838
}
18491839

0 commit comments

Comments
 (0)