@@ -494,33 +494,6 @@ void RequireLiveness::process(Collection requireInstList) {
494
494
495
495
namespace {
496
496
497
- struct AssignIsolatedIntoOutSendingParameterInfo {
498
- // / The user that actually caused the transfer.
499
- Operand *srcOperand;
500
-
501
- // / The specific out sending result.
502
- SILFunctionArgument *outSendingResult;
503
-
504
- // / The non-transferrable value that is in the same region as \p
505
- // / outSendingResult.
506
- SILValue nonTransferrableValue;
507
-
508
- // / The region info that describes the dynamic dataflow derived isolation
509
- // / region info for the non-transferrable value.
510
- // /
511
- // / This is equal to the merge of the IsolationRegionInfo from all elements in
512
- // / nonTransferrable's region when the error was diagnosed.
513
- SILDynamicMergedIsolationInfo isolatedValueIsolationRegionInfo;
514
-
515
- AssignIsolatedIntoOutSendingParameterInfo (
516
- Operand *transferringOperand, SILFunctionArgument *outSendingResult,
517
- SILValue nonTransferrableValue,
518
- SILDynamicMergedIsolationInfo isolationRegionInfo)
519
- : srcOperand(transferringOperand), outSendingResult(outSendingResult),
520
- nonTransferrableValue (nonTransferrableValue),
521
- isolatedValueIsolationRegionInfo(isolationRegionInfo) {}
522
- };
523
-
524
497
// / Wrapper around a SILInstruction that internally specifies whether we are
525
498
// / dealing with an inout reinitialization needed or if it is just a normal
526
499
// / use after transfer.
@@ -557,8 +530,6 @@ class TransferNonSendableImpl {
557
530
SmallFrozenMultiMap<Operand *, RequireInst, 8 >
558
531
transferOpToRequireInstMultiMap;
559
532
SmallVector<PartitionOpError, 8 > foundVerbatimErrors;
560
- SmallVector<AssignIsolatedIntoOutSendingParameterInfo, 8 >
561
- assignIsolatedIntoOutSendingParameterInfoList;
562
533
563
534
public:
564
535
TransferNonSendableImpl (RegionAnalysisFunctionInfo *info) : info(info) {}
@@ -569,7 +540,6 @@ class TransferNonSendableImpl {
569
540
void runDiagnosticEvaluator ();
570
541
571
542
void emitUseAfterTransferDiagnostics ();
572
- void emitAssignIsolatedIntoSendingResultDiagnostics ();
573
543
void emitVerbatimErrors ();
574
544
};
575
545
@@ -2126,13 +2096,33 @@ void InOutSendingNotDisconnectedDiagnosticEmitter::emit() {
2126
2096
namespace {
2127
2097
2128
2098
class AssignIsolatedIntoSendingResultDiagnosticEmitter {
2129
- AssignIsolatedIntoOutSendingParameterInfo info;
2099
+ // / The user that actually caused the transfer.
2100
+ Operand *srcOperand;
2101
+
2102
+ // / The specific out sending result.
2103
+ SILFunctionArgument *outSendingResult;
2104
+
2105
+ // / The non-transferrable value that is in the same region as \p
2106
+ // / outSendingResult.
2107
+ SILValue nonTransferrableValue;
2108
+
2109
+ // / The region info that describes the dynamic dataflow derived isolation
2110
+ // / region info for the non-transferrable value.
2111
+ // /
2112
+ // / This is equal to the merge of the IsolationRegionInfo from all elements in
2113
+ // / nonTransferrable's region when the error was diagnosed.
2114
+ SILDynamicMergedIsolationInfo isolatedValueIsolationRegionInfo;
2115
+
2130
2116
bool emittedErrorDiagnostic = false ;
2131
2117
2132
2118
public:
2133
2119
AssignIsolatedIntoSendingResultDiagnosticEmitter (
2134
- AssignIsolatedIntoOutSendingParameterInfo info)
2135
- : info(info) {}
2120
+ Operand *srcOperand, SILFunctionArgument *outSendingResult,
2121
+ SILValue nonTransferrableValue,
2122
+ SILDynamicMergedIsolationInfo isolatedValueIsolationRegionInfo)
2123
+ : srcOperand(srcOperand), outSendingResult(outSendingResult),
2124
+ nonTransferrableValue (nonTransferrableValue),
2125
+ isolatedValueIsolationRegionInfo(isolatedValueIsolationRegionInfo) {}
2136
2126
2137
2127
~AssignIsolatedIntoSendingResultDiagnosticEmitter () {
2138
2128
// If we were supposed to emit a diagnostic and didn't emit an unknown
@@ -2141,10 +2131,10 @@ class AssignIsolatedIntoSendingResultDiagnosticEmitter {
2141
2131
emitUnknownPatternError ();
2142
2132
}
2143
2133
2144
- SILFunction *getFunction () const { return info. srcOperand ->getFunction (); }
2134
+ SILFunction *getFunction () const { return srcOperand->getFunction (); }
2145
2135
2146
2136
std::optional<DiagnosticBehavior> getConcurrencyDiagnosticBehavior () const {
2147
- return info. outSendingResult ->getType ().getConcurrencyDiagnosticBehavior (
2137
+ return outSendingResult->getType ().getConcurrencyDiagnosticBehavior (
2148
2138
getFunction ());
2149
2139
}
2150
2140
@@ -2154,15 +2144,15 @@ class AssignIsolatedIntoSendingResultDiagnosticEmitter {
2154
2144
" RegionIsolation: Aborting on unknown pattern match error" );
2155
2145
}
2156
2146
2157
- diagnoseError (info. srcOperand ->getUser (),
2147
+ diagnoseError (srcOperand->getUser (),
2158
2148
diag::regionbasedisolation_unknown_pattern)
2159
2149
.limitBehaviorIf (getConcurrencyDiagnosticBehavior ());
2160
2150
}
2161
2151
2162
2152
void emit ();
2163
2153
2164
2154
ASTContext &getASTContext () const {
2165
- return info. srcOperand ->getFunction ()->getASTContext ();
2155
+ return srcOperand->getFunction ()->getASTContext ();
2166
2156
}
2167
2157
2168
2158
template <typename ... T, typename ... U>
@@ -2243,32 +2233,31 @@ void AssignIsolatedIntoSendingResultDiagnosticEmitter::emit() {
2243
2233
SmallString<64 > descriptiveKindStr;
2244
2234
{
2245
2235
llvm::raw_svector_ostream os (descriptiveKindStr);
2246
- info. isolatedValueIsolationRegionInfo .printForDiagnostics (os);
2236
+ isolatedValueIsolationRegionInfo.printForDiagnostics (os);
2247
2237
}
2248
2238
2249
2239
// Grab the var name if we can find it.
2250
- if (auto varName = VariableNameInferrer::inferName (info. srcOperand ->get ())) {
2240
+ if (auto varName = VariableNameInferrer::inferName (srcOperand->get ())) {
2251
2241
// In general, when we do an assignment like this, we assume that srcOperand
2252
2242
// and our outSendingResult have the same type. This doesn't always happen
2253
2243
// though especially if our outSendingResult is used as an out parameter of
2254
2244
// a class_method. Check for such a case and if so, add to the end of our
2255
2245
// string a path component for that class_method.
2256
- if (info. srcOperand ->get ()->getType () != info. outSendingResult ->getType ()) {
2257
- if (auto fas = FullApplySite::isa (info. srcOperand ->getUser ())) {
2246
+ if (srcOperand->get ()->getType () != outSendingResult->getType ()) {
2247
+ if (auto fas = FullApplySite::isa (srcOperand->getUser ())) {
2258
2248
if (fas.hasSelfArgument () &&
2259
- fas.getSelfArgument () == info. srcOperand ->get () &&
2249
+ fas.getSelfArgument () == srcOperand->get () &&
2260
2250
fas.getNumIndirectSILResults () == 1 ) {
2261
2251
// First check if our function argument is exactly our out parameter.
2262
- bool canEmit =
2263
- info.outSendingResult == fas.getIndirectSILResults ()[0 ];
2252
+ bool canEmit = outSendingResult == fas.getIndirectSILResults ()[0 ];
2264
2253
2265
2254
// If that fails, see if we are storing into a temporary
2266
2255
// alloc_stack. In such a case, find the root value that the temporary
2267
2256
// is initialized to and see if that is our target function
2268
2257
// argument. In such a case, we also want to add the decl name to our
2269
2258
// type.
2270
2259
if (!canEmit) {
2271
- canEmit = info. outSendingResult ==
2260
+ canEmit = outSendingResult ==
2272
2261
findOutParameter (fas.getIndirectSILResults ()[0 ]);
2273
2262
}
2274
2263
@@ -2289,42 +2278,35 @@ void AssignIsolatedIntoSendingResultDiagnosticEmitter::emit() {
2289
2278
}
2290
2279
2291
2280
diagnoseError (
2292
- info. srcOperand ,
2281
+ srcOperand,
2293
2282
diag::regionbasedisolation_out_sending_cannot_be_actor_isolated_named,
2294
2283
*varName, descriptiveKindStr)
2295
2284
.limitBehaviorIf (getConcurrencyDiagnosticBehavior ());
2296
2285
2297
2286
diagnoseNote (
2298
- info. srcOperand ,
2287
+ srcOperand,
2299
2288
diag::
2300
2289
regionbasedisolation_out_sending_cannot_be_actor_isolated_note_named,
2301
2290
*varName, descriptiveKindStr);
2302
2291
return ;
2303
2292
}
2304
2293
2305
- Type type = info. nonTransferrableValue ->getType ().getASTType ();
2294
+ Type type = nonTransferrableValue->getType ().getASTType ();
2306
2295
2307
2296
diagnoseError (
2308
- info. srcOperand ,
2297
+ srcOperand,
2309
2298
diag::regionbasedisolation_out_sending_cannot_be_actor_isolated_type,
2310
2299
type, descriptiveKindStr)
2311
2300
.limitBehaviorIf (getConcurrencyDiagnosticBehavior ());
2312
2301
2313
2302
diagnoseNote (
2314
- info. srcOperand ,
2303
+ srcOperand,
2315
2304
diag::regionbasedisolation_out_sending_cannot_be_actor_isolated_note_type,
2316
2305
type, descriptiveKindStr);
2317
- diagnoseNote (info. srcOperand , diag::regionbasedisolation_type_is_non_sendable,
2306
+ diagnoseNote (srcOperand, diag::regionbasedisolation_type_is_non_sendable,
2318
2307
type);
2319
2308
}
2320
2309
2321
- void TransferNonSendableImpl::emitAssignIsolatedIntoSendingResultDiagnostics () {
2322
- for (auto &info : assignIsolatedIntoOutSendingParameterInfoList) {
2323
- AssignIsolatedIntoSendingResultDiagnosticEmitter emitter (info);
2324
- emitter.emit ();
2325
- }
2326
- }
2327
-
2328
2310
// ===----------------------------------------------------------------------===//
2329
2311
// MARK: Diagnostic Evaluator
2330
2312
// ===----------------------------------------------------------------------===//
@@ -2343,27 +2325,17 @@ struct DiagnosticEvaluator final
2343
2325
// / sending operands to require insts.
2344
2326
SmallVectorImpl<PartitionOpError> &foundVerbatimErrors;
2345
2327
2346
- // / A list of state that tracks specific 'inout sending' parameters that were
2347
- // / actor isolated on function exit with the necessary state to emit the
2348
- // / error.
2349
- SmallVectorImpl<AssignIsolatedIntoOutSendingParameterInfo>
2350
- &assignIsolatedIntoOutSendingParameterInfoList;
2351
-
2352
2328
DiagnosticEvaluator (Partition &workingPartition,
2353
2329
RegionAnalysisFunctionInfo *info,
2354
2330
SmallFrozenMultiMap<Operand *, RequireInst, 8 >
2355
2331
&transferOpToRequireInstMultiMap,
2356
2332
SmallVectorImpl<PartitionOpError> &foundVerbatimErrors,
2357
- SmallVectorImpl<AssignIsolatedIntoOutSendingParameterInfo>
2358
- &assignIsolatedIntoOutSendingParameterInfo,
2359
2333
TransferringOperandToStateMap &operandToStateMap)
2360
2334
: PartitionOpEvaluatorBaseImpl(
2361
2335
workingPartition, info->getOperandSetFactory (), operandToStateMap),
2362
2336
info(info),
2363
2337
transferOpToRequireInstMultiMap(transferOpToRequireInstMultiMap),
2364
- foundVerbatimErrors(foundVerbatimErrors),
2365
- assignIsolatedIntoOutSendingParameterInfoList(
2366
- assignIsolatedIntoOutSendingParameterInfo) {}
2338
+ foundVerbatimErrors(foundVerbatimErrors) {}
2367
2339
2368
2340
void handleLocalUseAfterTransfer (LocalUseAfterSendError error) const {
2369
2341
const auto &partitionOp = *error.op ;
@@ -2401,29 +2373,6 @@ struct DiagnosticEvaluator final
2401
2373
RequireInst::forUseAfterTransfer (partitionOp.getSourceInst ()));
2402
2374
}
2403
2375
2404
- void handleAssignTransferNonTransferrableIntoSendingResult (
2405
- AssignNeverSendableIntoSendingResultError error) const {
2406
- const PartitionOp &partitionOp = *error.op ;
2407
- Element destElement = error.destElement ;
2408
- SILFunctionArgument *destValue = error.destValue ;
2409
- Element srcElement = error.srcElement ;
2410
- SILValue srcValue = error.srcValue ;
2411
- auto srcIsolationRegionInfo = error.srcIsolationRegionInfo ;
2412
- auto srcRep = info->getValueMap ().getRepresentativeValue (srcElement);
2413
- REGIONBASEDISOLATION_LOG (
2414
- llvm::dbgs ()
2415
- << " Emitting Error. Kind: Assign Isolated Into Sending Result!\n "
2416
- << " Assign Inst: " << *partitionOp.getSourceInst ()
2417
- << " Dest Value: " << *destValue
2418
- << " Dest Element: " << destElement << ' \n '
2419
- << " Src Value: " << srcValue
2420
- << " Src Element: " << srcElement << ' \n '
2421
- << " Src Rep: " << srcRep
2422
- << " Src Isolation: " << srcIsolationRegionInfo << ' \n ' );
2423
- assignIsolatedIntoOutSendingParameterInfoList.emplace_back (
2424
- partitionOp.getSourceOp (), destValue, srcValue, srcIsolationRegionInfo);
2425
- }
2426
-
2427
2376
void handleInOutSendingNotInitializedAtExitError (
2428
2377
InOutSendingNotInitializedAtExitError error) const {
2429
2378
const PartitionOp &partitionOp = *error.op ;
@@ -2465,12 +2414,9 @@ struct DiagnosticEvaluator final
2465
2414
}
2466
2415
case PartitionOpError::InOutSendingNotDisconnectedAtExit:
2467
2416
case PartitionOpError::SentNeverSendable:
2417
+ case PartitionOpError::AssignNeverSendableIntoSendingResult:
2468
2418
foundVerbatimErrors.emplace_back (error);
2469
2419
return ;
2470
- case PartitionOpError::AssignNeverSendableIntoSendingResult: {
2471
- return handleAssignTransferNonTransferrableIntoSendingResult (
2472
- error.getAssignNeverSendableIntoSendingResultError ());
2473
- }
2474
2420
case PartitionOpError::InOutSendingNotInitializedAtExit: {
2475
2421
return handleInOutSendingNotInitializedAtExitError (
2476
2422
error.getInOutSendingNotInitializedAtExitError ());
@@ -2544,8 +2490,7 @@ void TransferNonSendableImpl::runDiagnosticEvaluator() {
2544
2490
Partition workingPartition = blockState.getEntryPartition ();
2545
2491
DiagnosticEvaluator eval (
2546
2492
workingPartition, info, transferOpToRequireInstMultiMap,
2547
- foundVerbatimErrors, assignIsolatedIntoOutSendingParameterInfoList,
2548
- info->getTransferringOpToStateMap ());
2493
+ foundVerbatimErrors, info->getTransferringOpToStateMap ());
2549
2494
2550
2495
// And then evaluate all of our partition ops on the entry partition.
2551
2496
for (auto &partitionOp : blockState.getPartitionOps ()) {
@@ -2572,10 +2517,28 @@ void TransferNonSendableImpl::emitVerbatimErrors() {
2572
2517
switch (erasedError.getKind ()) {
2573
2518
case PartitionOpError::UnknownCodePattern:
2574
2519
case PartitionOpError::LocalUseAfterSend:
2575
- llvm_unreachable (" Handled elsewhere" );
2576
- case PartitionOpError::AssignNeverSendableIntoSendingResult:
2577
2520
case PartitionOpError::InOutSendingNotInitializedAtExit:
2578
- llvm_unreachable (" Not implemented yet" );
2521
+ llvm_unreachable (" Handled elsewhere" );
2522
+ case PartitionOpError::AssignNeverSendableIntoSendingResult: {
2523
+ auto error = erasedError.getAssignNeverSendableIntoSendingResultError ();
2524
+ auto srcRep =
2525
+ info->getValueMap ().getRepresentativeValue (error.srcElement );
2526
+ REGIONBASEDISOLATION_LOG (
2527
+ llvm::dbgs ()
2528
+ << " Emitting Error. Kind: Assign Isolated Into Sending Result!\n "
2529
+ << " Assign Inst: " << *error.op ->getSourceInst ()
2530
+ << " Dest Value: " << *error.destValue
2531
+ << " Dest Element: " << error.destElement << ' \n '
2532
+ << " Src Value: " << error.srcValue
2533
+ << " Src Element: " << error.srcElement << ' \n '
2534
+ << " Src Rep: " << srcRep
2535
+ << " Src Isolation: " << error.srcIsolationRegionInfo << ' \n ' );
2536
+ AssignIsolatedIntoSendingResultDiagnosticEmitter emitter (
2537
+ error.op ->getSourceOp (), error.destValue , error.srcValue ,
2538
+ error.srcIsolationRegionInfo );
2539
+ emitter.emit ();
2540
+ continue ;
2541
+ }
2579
2542
case PartitionOpError::InOutSendingNotDisconnectedAtExit: {
2580
2543
auto error = erasedError.getInOutSendingNotDisconnectedAtExitError ();
2581
2544
auto inoutSendingVal =
@@ -2641,7 +2604,6 @@ void TransferNonSendableImpl::emitDiagnostics() {
2641
2604
2642
2605
runDiagnosticEvaluator ();
2643
2606
emitUseAfterTransferDiagnostics ();
2644
- emitAssignIsolatedIntoSendingResultDiagnostics ();
2645
2607
emitVerbatimErrors ();
2646
2608
}
2647
2609
0 commit comments