@@ -1369,16 +1369,13 @@ class BlockPartitionState {
13691369 // / The basic block that this state belongs to.
13701370 SILBasicBlock *basicBlock;
13711371
1372- // / The translator that we use to initialize our PartitionOps.
1373- PartitionOpTranslator &translator;
1374-
13751372 // / The vector of PartitionOps that are used to perform the dataflow in this
13761373 // / block.
13771374 std::vector<PartitionOp> blockPartitionOps = {};
13781375
13791376 BlockPartitionState (SILBasicBlock *basicBlock,
13801377 PartitionOpTranslator &translator)
1381- : basicBlock(basicBlock), translator(translator) {
1378+ : basicBlock(basicBlock) {
13821379 translator.translateSILBasicBlock (basicBlock, blockPartitionOps);
13831380 }
13841381
@@ -1400,30 +1397,6 @@ class BlockPartitionState {
14001397 return exitUpdated;
14011398 }
14021399
1403- // / Once the dataflow has converged, rerun the dataflow from the
1404- // / entryPartition this time diagnosing errors as we apply the dataflow.
1405- void diagnoseFailures (
1406- llvm::function_ref<void (const PartitionOp &, TrackableValueID)>
1407- failureCallback,
1408- llvm::function_ref<void(const PartitionOp &, TrackableValueID)>
1409- transferredNonTransferrableCallback) {
1410- Partition workingPartition = entryPartition;
1411- PartitionOpEvaluator eval (workingPartition);
1412- eval.failureCallback = failureCallback;
1413- eval.transferredNonTransferrableCallback =
1414- transferredNonTransferrableCallback;
1415- eval.nonTransferrableElements = translator.getNeverTransferredValues ();
1416- eval.isActorDerivedCallback = [&](Element element) -> bool {
1417- auto iter = translator.getValueForId (element);
1418- if (!iter)
1419- return false ;
1420- return iter->isActorDerived ();
1421- };
1422- for (auto &partitionOp : blockPartitionOps) {
1423- eval.apply (partitionOp);
1424- }
1425- }
1426-
14271400public:
14281401 // / Run the passed action on each partitionOp in this block. Action should
14291402 // / return true iff iteration should continue.
@@ -1434,6 +1407,8 @@ class BlockPartitionState {
14341407 break ;
14351408 }
14361409
1410+ ArrayRef<PartitionOp> getPartitionOps () const { return blockPartitionOps; }
1411+
14371412 const Partition &getEntryPartition () const { return entryPartition; }
14381413
14391414 const Partition &getExitPartition () const { return exitPartition; }
@@ -2126,13 +2101,15 @@ class PartitionAnalysis {
21262101 << function->getName () << " \n " );
21272102 RaceTracer tracer (function, blockStates);
21282103
2104+ // Then for each block...
21292105 for (auto [block, blockState] : blockStates) {
21302106 LLVM_DEBUG (llvm::dbgs () << " |--> Block bb" << block.getDebugID () << " \n " );
21312107
2132- // populate the raceTracer with all requires of transferred valued found
2133- // throughout the CFG
2134- blockState.diagnoseFailures (
2135- /* handleFailure=*/
2108+ // Grab its entry partition and setup an evaluator for the partition that
2109+ // has callbacks that emit diagnsotics...
2110+ Partition workingPartition = blockState.getEntryPartition ();
2111+ PartitionOpEvaluator eval (workingPartition);
2112+ eval.failureCallback = /* handleFailure=*/
21362113 [&](const PartitionOp &partitionOp, TrackableValueID transferredVal) {
21372114 auto expr = getExprForPartitionOp (partitionOp);
21382115
@@ -2149,9 +2126,8 @@ class PartitionAnalysis {
21492126 ->getRepresentative ());
21502127
21512128 raceTracer.traceUseOfTransferredValue (partitionOp, transferredVal);
2152- },
2153-
2154- /* handleTransferNonTransferrable=*/
2129+ };
2130+ eval.transferredNonTransferrableCallback =
21552131 [&](const PartitionOp &partitionOp, TrackableValueID transferredVal) {
21562132 LLVM_DEBUG (llvm::dbgs ()
21572133 << " Emitting TransferNonTransferrable Error!\n "
@@ -2162,14 +2138,26 @@ class PartitionAnalysis {
21622138 auto expr = getExprForPartitionOp (partitionOp);
21632139 function->getASTContext ().Diags .diagnose (
21642140 expr->getLoc (), diag::arg_region_transferred);
2165- });
2141+ };
2142+ eval.nonTransferrableElements = translator.getNeverTransferredValues ();
2143+ eval.isActorDerivedCallback = [&](Element element) -> bool {
2144+ auto iter = translator.getValueForId (element);
2145+ if (!iter)
2146+ return false ;
2147+ return iter->isActorDerived ();
2148+ };
2149+
2150+ // And then evaluate all of our partition ops on the entry partition.
2151+ for (auto &partitionOp : blockState.getPartitionOps ()) {
2152+ eval.apply (partitionOp);
2153+ }
21662154 }
21672155
2156+ // Once we have run over all backs, dump the accumulator and ask the
2157+ // raceTracer to report diagnostics at the transfer sites for all the racy
2158+ // requirement sites entered into it above.
21682159 LLVM_DEBUG (llvm::dbgs () << " Accumulator Complete:\n " ;
21692160 raceTracer.getAccumulator ().print (llvm::dbgs ()););
2170-
2171- // Ask the raceTracer to report diagnostics at the transfer sites for all
2172- // the racy requirement sites entered into it above.
21732161 raceTracer.getAccumulator ().emitErrorsForTransferRequire (
21742162 NUM_REQUIREMENTS_TO_DIAGNOSE);
21752163 }
0 commit comments