@@ -1369,16 +1369,13 @@ class BlockPartitionState {
1369
1369
// / The basic block that this state belongs to.
1370
1370
SILBasicBlock *basicBlock;
1371
1371
1372
- // / The translator that we use to initialize our PartitionOps.
1373
- PartitionOpTranslator &translator;
1374
-
1375
1372
// / The vector of PartitionOps that are used to perform the dataflow in this
1376
1373
// / block.
1377
1374
std::vector<PartitionOp> blockPartitionOps = {};
1378
1375
1379
1376
BlockPartitionState (SILBasicBlock *basicBlock,
1380
1377
PartitionOpTranslator &translator)
1381
- : basicBlock(basicBlock), translator(translator) {
1378
+ : basicBlock(basicBlock) {
1382
1379
translator.translateSILBasicBlock (basicBlock, blockPartitionOps);
1383
1380
}
1384
1381
@@ -1400,30 +1397,6 @@ class BlockPartitionState {
1400
1397
return exitUpdated;
1401
1398
}
1402
1399
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
-
1427
1400
public:
1428
1401
// / Run the passed action on each partitionOp in this block. Action should
1429
1402
// / return true iff iteration should continue.
@@ -1434,6 +1407,8 @@ class BlockPartitionState {
1434
1407
break ;
1435
1408
}
1436
1409
1410
+ ArrayRef<PartitionOp> getPartitionOps () const { return blockPartitionOps; }
1411
+
1437
1412
const Partition &getEntryPartition () const { return entryPartition; }
1438
1413
1439
1414
const Partition &getExitPartition () const { return exitPartition; }
@@ -2126,13 +2101,15 @@ class PartitionAnalysis {
2126
2101
<< function->getName () << " \n " );
2127
2102
RaceTracer tracer (function, blockStates);
2128
2103
2104
+ // Then for each block...
2129
2105
for (auto [block, blockState] : blockStates) {
2130
2106
LLVM_DEBUG (llvm::dbgs () << " |--> Block bb" << block.getDebugID () << " \n " );
2131
2107
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=*/
2136
2113
[&](const PartitionOp &partitionOp, TrackableValueID transferredVal) {
2137
2114
auto expr = getExprForPartitionOp (partitionOp);
2138
2115
@@ -2149,9 +2126,8 @@ class PartitionAnalysis {
2149
2126
->getRepresentative ());
2150
2127
2151
2128
raceTracer.traceUseOfTransferredValue (partitionOp, transferredVal);
2152
- },
2153
-
2154
- /* handleTransferNonTransferrable=*/
2129
+ };
2130
+ eval.transferredNonTransferrableCallback =
2155
2131
[&](const PartitionOp &partitionOp, TrackableValueID transferredVal) {
2156
2132
LLVM_DEBUG (llvm::dbgs ()
2157
2133
<< " Emitting TransferNonTransferrable Error!\n "
@@ -2162,14 +2138,26 @@ class PartitionAnalysis {
2162
2138
auto expr = getExprForPartitionOp (partitionOp);
2163
2139
function->getASTContext ().Diags .diagnose (
2164
2140
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
+ }
2166
2154
}
2167
2155
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.
2168
2159
LLVM_DEBUG (llvm::dbgs () << " Accumulator Complete:\n " ;
2169
2160
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.
2173
2161
raceTracer.getAccumulator ().emitErrorsForTransferRequire (
2174
2162
NUM_REQUIREMENTS_TO_DIAGNOSE);
2175
2163
}
0 commit comments