Skip to content

Commit 6f66849

Browse files
committed
[region-isolation] Do not squelch errors in the unittests.
To squelch errors, we need access to functionality not available in the unittests. The unittests do not require this functionality anyways, so just disable squelching during the unittests.
1 parent e36aab6 commit 6f66849

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -875,27 +875,37 @@ struct PartitionOpEvaluator {
875875
apply(o);
876876
}
877877

878+
/// Provides a way for subclasses to disable the error squelching
879+
/// functionality.
880+
///
881+
/// Used by the unittests.
882+
bool shouldTryToSquelchErrors() const {
883+
return asImpl().shouldTryToSquelchErrors();
884+
}
885+
878886
private:
879887
// Private helper that squelches the error if our transfer instruction and our
880888
// use have the same isolation.
881889
void
882890
handleLocalUseAfterTransferHelper(const PartitionOp &op, Element elt,
883891
TransferringOperand *transferringOp) const {
884-
if (auto isolationInfo = SILIsolationInfo::get(op.getSourceInst())) {
885-
if (isolationInfo.isActorIsolated() &&
886-
isolationInfo == SILIsolationInfo::get(transferringOp->getUser()))
887-
return;
888-
}
892+
if (shouldTryToSquelchErrors()) {
893+
if (auto isolationInfo = SILIsolationInfo::get(op.getSourceInst())) {
894+
if (isolationInfo.isActorIsolated() &&
895+
isolationInfo == SILIsolationInfo::get(transferringOp->getUser()))
896+
return;
897+
}
889898

890-
// If our instruction does not have any isolation info associated with it,
891-
// it must be nonisolated. See if our function has a matching isolation to
892-
// our transferring operand. If so, we can squelch this.
893-
if (auto functionIsolation =
894-
transferringOp->getUser()->getFunction()->getActorIsolation()) {
895-
if (functionIsolation->isActorIsolated() &&
896-
SILIsolationInfo::getActorIsolated(*functionIsolation) ==
897-
SILIsolationInfo::get(transferringOp->getUser()))
898-
return;
899+
// If our instruction does not have any isolation info associated with it,
900+
// it must be nonisolated. See if our function has a matching isolation to
901+
// our transferring operand. If so, we can squelch this.
902+
if (auto functionIsolation =
903+
transferringOp->getUser()->getFunction()->getActorIsolation()) {
904+
if (functionIsolation->isActorIsolated() &&
905+
SILIsolationInfo::getActorIsolated(*functionIsolation) ==
906+
SILIsolationInfo::get(transferringOp->getUser()))
907+
return;
908+
}
899909
}
900910

901911
// Ok, we actually need to emit a call to the callback.
@@ -970,6 +980,9 @@ struct PartitionOpEvaluatorBaseImpl : PartitionOpEvaluator<Subclass> {
970980
/// to access the instruction in the evaluator which creates a problem when
971981
/// since the operand we pass in is a dummy operand.
972982
bool isClosureCaptured(Element elt, Operand *op) const { return false; }
983+
984+
/// By default squelch errors.
985+
bool shouldTryToSquelchErrors() const { return true; }
973986
};
974987

975988
/// A subclass of PartitionOpEvaluatorBaseImpl that doesn't have any special

unittests/SILOptimizer/PartitionUtilsTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ struct MockedPartitionOpEvaluator final
4747
SILIsolationInfo getIsolationRegionInfo(Element elt) const {
4848
return SILIsolationInfo::getDisconnected();
4949
}
50+
51+
bool shouldTryToSquelchErrors() const { return false; }
5052
};
5153

5254
} // namespace
@@ -566,6 +568,8 @@ struct MockedPartitionOpEvaluatorWithFailureCallback final
566568
SILIsolationInfo getIsolationRegionInfo(Element elt) const {
567569
return SILIsolationInfo::getDisconnected();
568570
}
571+
572+
bool shouldTryToSquelchErrors() const { return false; }
569573
};
570574

571575
} // namespace

0 commit comments

Comments
 (0)