Skip to content

Commit d252902

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.
1 parent f1d2740 commit d252902

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
@@ -1354,7 +1354,6 @@ struct GatherUsesVisitor final : public TransitiveAddressWalker {
13541354
MoveOnlyAddressCheckerPImpl &moveChecker;
13551355
UseState &useState;
13561356
MarkMustCheckInst *markedValue;
1357-
bool emittedEarlyDiagnostic = false;
13581357
DiagnosticEmitter &diagnosticEmitter;
13591358

13601359
// Pruned liveness used to validate that load [take]/load [copy] can be
@@ -1529,14 +1528,13 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
15291528
if (isa<ProjectBoxInst>(stripAccessMarkers(markedValue->getOperand()))) {
15301529
LLVM_DEBUG(llvm::dbgs()
15311530
<< "Found mark must check [nocopy] use of escaping box: " << *user);
1532-
diagnosticEmitter.emitAddressEscapingClosureCaptureLoadedAndConsumed(markedValue);
1533-
emittedEarlyDiagnostic = true;
1531+
diagnosticEmitter.emitAddressEscapingClosureCaptureLoadedAndConsumed(
1532+
markedValue);
15341533
return true;
15351534
}
15361535
LLVM_DEBUG(llvm::dbgs()
15371536
<< "Found mark must check [nocopy] error: " << *user);
15381537
diagnosticEmitter.emitAddressDiagnosticNoCopy(markedValue, copyAddr);
1539-
emittedEarlyDiagnostic = true;
15401538
return true;
15411539
}
15421540

@@ -1592,15 +1590,13 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
15921590
.didEmitCheckerDoesntUnderstandDiagnostic());
15931591
LLVM_DEBUG(llvm::dbgs()
15941592
<< "Failed to perform borrow to destructure transform!\n");
1595-
emittedEarlyDiagnostic = true;
15961593
return false;
15971594
}
15981595

15991596
// If we emitted an error diagnostic, do not transform further and instead
16001597
// mark that we emitted an early diagnostic and return true.
16011598
if (numDiagnostics != moveChecker.diagnosticEmitter.getDiagnosticCount()) {
16021599
LLVM_DEBUG(llvm::dbgs() << "Emitting borrow to destructure error!\n");
1603-
emittedEarlyDiagnostic = true;
16041600
return true;
16051601
}
16061602

@@ -1621,7 +1617,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
16211617
if (numDiagnostics != moveChecker.diagnosticEmitter.getDiagnosticCount()) {
16221618
LLVM_DEBUG(llvm::dbgs()
16231619
<< "Emitting destructure through deinit error!\n");
1624-
emittedEarlyDiagnostic = true;
16251620
return true;
16261621
}
16271622

@@ -1646,7 +1641,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
16461641
moveChecker.diagnosticEmitter
16471642
.emitAddressEscapingClosureCaptureLoadedAndConsumed(markedValue);
16481643
}
1649-
emittedEarlyDiagnostic = true;
16501644
return true;
16511645
}
16521646

@@ -1660,7 +1654,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
16601654

16611655
if (checkForExclusivityHazards(li)) {
16621656
LLVM_DEBUG(llvm::dbgs() << "Found exclusivity violation?!\n");
1663-
emittedEarlyDiagnostic = true;
16641657
return true;
16651658
}
16661659

@@ -1693,7 +1686,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
16931686
// succeeded.
16941687
// Otherwise, emit the diagnostic.
16951688
moveChecker.diagnosticEmitter.emitObjectOwnedDiagnostic(markedValue);
1696-
emittedEarlyDiagnostic = true;
16971689
LLVM_DEBUG(llvm::dbgs() << "Emitted early object level diagnostic.\n");
16981690
return true;
16991691
}
@@ -1702,7 +1694,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17021694
LLVM_DEBUG(llvm::dbgs() << "Found potential borrow inst: " << *user);
17031695
if (checkForExclusivityHazards(li)) {
17041696
LLVM_DEBUG(llvm::dbgs() << "Found exclusivity violation?!\n");
1705-
emittedEarlyDiagnostic = true;
17061697
return true;
17071698
}
17081699

@@ -1751,7 +1742,6 @@ bool GatherUsesVisitor::visitUse(Operand *op) {
17511742
moveChecker.diagnosticEmitter
17521743
.emitAddressEscapingClosureCaptureLoadedAndConsumed(markedValue);
17531744
}
1754-
emittedEarlyDiagnostic = true;
17551745
return true;
17561746
}
17571747

0 commit comments

Comments
 (0)