@@ -482,7 +482,7 @@ class PartitionOpTranslator {
482
482
for (SILArgument *arg : functionArguments) {
483
483
if (auto state = tryToTrackValue (arg)) {
484
484
// If we have an arg that is an actor, we allow for it to be
485
- // consumed ... value ids derived from it though cannot be consumed .
485
+ // transfer ... value ids derived from it though cannot be transferred .
486
486
LLVM_DEBUG (llvm::dbgs () << " %%" << state->getID ());
487
487
neverTransferredValueIDs.push_back (state->getID ());
488
488
nonSendableIndices.push_back (state->getID ());
@@ -1071,7 +1071,7 @@ class PartitionOpTranslator {
1071
1071
1072
1072
// We ignore begin_access since we look through them. We look through them
1073
1073
// since we want to treat the use of the begin_access as the semantic giving
1074
- // instruction. Otherwise, if we have a store after a consume we will emit
1074
+ // instruction. Otherwise, if we have a store after a transfer we will emit
1075
1075
// an error on the begin_access rather than allowing for the store to
1076
1076
// overwrite the original value. This would then cause an error.
1077
1077
//
@@ -1343,7 +1343,7 @@ struct LocalTransferredReason {
1343
1343
// / causes a target access to be invalid because of merging/joining that spans
1344
1344
// / many different blocks worth of control flow, it is less likely to be
1345
1345
// / informative, so distance is used as a heuristic to choose which access sites
1346
- // / to display in diagnostics given a racy consumption .
1346
+ // / to display in diagnostics given a racy transfer .
1347
1347
class TransferredReason {
1348
1348
std::multimap<unsigned , PartitionOp> transferOps;
1349
1349
@@ -1437,7 +1437,7 @@ class TransferRequireAccumulator {
1437
1437
unsigned numDisplayed = numProcessed;
1438
1438
unsigned numHidden = requireOps.size () - numProcessed;
1439
1439
if (!tryDiagnoseAsCallSite (transferOp, numDisplayed, numHidden)) {
1440
- assert (false && " no consumptions besides callsites implemented yet" );
1440
+ assert (false && " no transfers besides callsites implemented yet" );
1441
1441
1442
1442
// Default to a more generic diagnostic if we can't find the callsite.
1443
1443
auto expr = getExprForPartitionOp (transferOp);
@@ -1486,16 +1486,17 @@ class TransferRequireAccumulator {
1486
1486
SILInstruction *sourceInst =
1487
1487
transferOp.getSourceInst (/* assertNonNull=*/ true );
1488
1488
ApplyExpr *apply = sourceInst->getLoc ().getAsASTNode <ApplyExpr>();
1489
+
1490
+ // If the transfer does not correspond to an apply expression... bail.
1489
1491
if (!apply)
1490
- // consumption does not correspond to an apply expression
1491
1492
return false ;
1493
+
1492
1494
auto isolationCrossing = apply->getIsolationCrossing ();
1493
1495
assert (isolationCrossing && " ApplyExprs should be transferring only if "
1494
1496
" they are isolation crossing" );
1495
1497
1496
1498
auto argExpr = transferOp.getSourceExpr ();
1497
- assert (argExpr &&
1498
- " sourceExpr should be populated for ApplyExpr consumptions" );
1499
+ assert (argExpr && " sourceExpr should be populated for ApplyExpr transfers" );
1499
1500
1500
1501
sourceInst->getFunction ()
1501
1502
->getASTContext ()
@@ -1648,22 +1649,22 @@ class RaceTracer {
1648
1649
findLocalTransferredReason (SILBasicBlock *SILBlock,
1649
1650
TrackableValueID transferredVal,
1650
1651
std::optional<PartitionOp> targetOp = {}) {
1651
- // if this is a query for consumption reason at block exit, check the cache
1652
+ // If this is a query for transfer reason at block exit, check the cache.
1652
1653
if (!targetOp && transferredAtExitReasons.count ({SILBlock, transferredVal}))
1653
1654
return transferredAtExitReasons.at ({SILBlock, transferredVal});
1654
1655
1655
1656
const BlockPartitionState &block = blockStates[SILBlock];
1656
1657
1657
- // if targetOp is null, we're checking why the value is transferred at exit,
1658
+ // If targetOp is null, we're checking why the value is transferred at exit,
1658
1659
// so assert that it's actually transferred at exit
1659
1660
assert (targetOp || block.getExitPartition ().isTransferred (transferredVal));
1660
1661
1661
1662
std::optional<LocalTransferredReason> transferredReason;
1662
1663
1663
1664
Partition workingPartition = block.getEntryPartition ();
1664
1665
1665
- // we're looking for a local reason, so if the value is transferred at
1666
- // entry, revive it for the sake of this search
1666
+ // We are looking for a local reason, so if the value is transferred at
1667
+ // entry, revive it for the sake of this search.
1667
1668
if (workingPartition.isTransferred (transferredVal))
1668
1669
workingPartition.apply (PartitionOp::AssignFresh (transferredVal));
1669
1670
@@ -1674,35 +1675,35 @@ class RaceTracer {
1674
1675
workingPartition.apply (partitionOp);
1675
1676
if (workingPartition.isTransferred (transferredVal) &&
1676
1677
!transferredReason) {
1677
- // this partitionOp transfers the target value
1678
+ // This partitionOp transfers the target value.
1678
1679
if (partitionOp.getKind () == PartitionOpKind::Transfer)
1679
1680
transferredReason = LocalTransferredReason::TransferInst (partitionOp);
1680
1681
else
1681
- // a merge or assignment invalidated this, but that will be a separate
1682
- // failure to diagnose, so we don't worry about it here
1682
+ // A merge or assignment invalidated this, but that will be a separate
1683
+ // failure to diagnose, so we don't worry about it here.
1683
1684
transferredReason = LocalTransferredReason::NonTransferInst ();
1684
1685
}
1685
1686
if (!workingPartition.isTransferred (transferredVal) && transferredReason)
1686
- // value is no longer transferred - e.g. reassigned or assigned fresh
1687
+ // Value is no longer transferred - e.g. reassigned or assigned fresh.
1687
1688
transferredReason = llvm::None;
1688
1689
1689
1690
// continue walking block
1690
1691
i++;
1691
1692
return true ;
1692
1693
});
1693
1694
1694
- // if we failed to find a local transfer reason, but the value was
1695
- // transferred at entry to the block, then the reason is "NonLocal"
1695
+ // If we failed to find a local transfer reason, but the value was
1696
+ // transferred at entry to the block, then the reason is "NonLocal".
1696
1697
if (!transferredReason &&
1697
1698
block.getEntryPartition ().isTransferred (transferredVal))
1698
1699
transferredReason = LocalTransferredReason::NonLocal ();
1699
1700
1700
- // if transferredReason is none, then transferredVal was not actually
1701
- // transferred
1701
+ // If transferredReason is none, then transferredVal was not actually
1702
+ // transferred.
1702
1703
assert (transferredReason || dumpBlockSearch (SILBlock, transferredVal) &&
1703
- " no consumption was found" );
1704
+ " no transfer was found" );
1704
1705
1705
- // if this is a query for consumption reason at block exit, update the cache
1706
+ // If this is a query for a transfer reason at block exit, update the cache.
1706
1707
if (!targetOp)
1707
1708
return transferredAtExitReasons[std::pair{SILBlock, transferredVal}] =
1708
1709
transferredReason.value ();
@@ -1908,7 +1909,7 @@ class PartitionAnalysis {
1908
1909
[&](const PartitionOp &partitionOp, TrackableValueID transferredVal) {
1909
1910
auto expr = getExprForPartitionOp (partitionOp);
1910
1911
1911
- // ensure that multiple consumptions at the same AST node are only
1912
+ // ensure that multiple transfers at the same AST node are only
1912
1913
// entered once into the race tracer
1913
1914
if (hasBeenEmitted (expr))
1914
1915
return ;
@@ -1923,10 +1924,10 @@ class PartitionAnalysis {
1923
1924
raceTracer.traceUseOfTransferredValue (partitionOp, transferredVal);
1924
1925
},
1925
1926
1926
- /* handleTransferNonConsumable =*/
1927
+ /* handleTransferNonTransferrable =*/
1927
1928
[&](const PartitionOp &partitionOp, TrackableValueID transferredVal) {
1928
1929
LLVM_DEBUG (llvm::dbgs ()
1929
- << " Emitting ConsumeNonConsume Error!\n "
1930
+ << " Emitting TransferNonTransferrable Error!\n "
1930
1931
<< " ID: %%" << transferredVal << " \n "
1931
1932
<< " Rep: "
1932
1933
<< *translator.getValueForId (transferredVal)
@@ -1940,7 +1941,7 @@ class PartitionAnalysis {
1940
1941
LLVM_DEBUG (llvm::dbgs () << " Accumulator Complete:\n " ;
1941
1942
raceTracer.getAccumulator ().print (llvm::dbgs ()););
1942
1943
1943
- // Ask the raceTracer to report diagnostics at the consumption sites for all
1944
+ // Ask the raceTracer to report diagnostics at the transfer sites for all
1944
1945
// the racy requirement sites entered into it above.
1945
1946
raceTracer.getAccumulator ().emitErrorsForTransferRequire (
1946
1947
NUM_REQUIREMENTS_TO_DIAGNOSE);
@@ -1951,9 +1952,12 @@ class PartitionAnalysis {
1951
1952
SILInstruction *sourceInst =
1952
1953
transferOp.getSourceInst (/* assertNonNull=*/ true );
1953
1954
ApplyExpr *apply = sourceInst->getLoc ().getAsASTNode <ApplyExpr>();
1955
+
1956
+ // If the transfer does not correspond to an apply expression... return
1957
+ // early.
1954
1958
if (!apply)
1955
- // consumption does not correspond to an apply expression
1956
1959
return false ;
1960
+
1957
1961
auto isolationCrossing = apply->getIsolationCrossing ();
1958
1962
if (!isolationCrossing) {
1959
1963
assert (false && " ApplyExprs should be transferring only if"
@@ -1962,8 +1966,7 @@ class PartitionAnalysis {
1962
1966
}
1963
1967
auto argExpr = transferOp.getSourceExpr ();
1964
1968
if (!argExpr)
1965
- assert (false &&
1966
- " sourceExpr should be populated for ApplyExpr consumptions" );
1969
+ assert (false && " sourceExpr should be populated for ApplyExpr transfers" );
1967
1970
1968
1971
function->getASTContext ()
1969
1972
.Diags
0 commit comments