@@ -494,26 +494,6 @@ void RequireLiveness::process(Collection requireInstList) {
494
494
495
495
namespace {
496
496
497
- struct InOutSendingNotDisconnectedInfo {
498
- // / The function exiting inst where the 'inout sending' parameter was actor
499
- // / isolated.
500
- TermInst *functionExitingInst;
501
-
502
- // / The 'inout sending' param that we are emitting an error for.
503
- SILValue inoutSendingParam;
504
-
505
- // / The dynamic actor isolated region info of our 'inout sending' value's
506
- // / region at the terminator inst.
507
- SILDynamicMergedIsolationInfo actorIsolatedRegionInfo;
508
-
509
- InOutSendingNotDisconnectedInfo (
510
- SILInstruction *functionExitingInst, SILValue inoutSendingParam,
511
- SILDynamicMergedIsolationInfo actorIsolatedRegionInfo)
512
- : functionExitingInst(cast<TermInst>(functionExitingInst)),
513
- inoutSendingParam (inoutSendingParam),
514
- actorIsolatedRegionInfo(actorIsolatedRegionInfo) {}
515
- };
516
-
517
497
struct AssignIsolatedIntoOutSendingParameterInfo {
518
498
// / The user that actually caused the transfer.
519
499
Operand *srcOperand;
@@ -577,8 +557,6 @@ class TransferNonSendableImpl {
577
557
SmallFrozenMultiMap<Operand *, RequireInst, 8 >
578
558
transferOpToRequireInstMultiMap;
579
559
SmallVector<PartitionOpError, 8 > foundVerbatimErrors;
580
- SmallVector<InOutSendingNotDisconnectedInfo, 8 >
581
- inoutSendingNotDisconnectedInfoList;
582
560
SmallVector<AssignIsolatedIntoOutSendingParameterInfo, 8 >
583
561
assignIsolatedIntoOutSendingParameterInfoList;
584
562
@@ -591,7 +569,6 @@ class TransferNonSendableImpl {
591
569
void runDiagnosticEvaluator ();
592
570
593
571
void emitUseAfterTransferDiagnostics ();
594
- void emitInOutSendingNotDisconnectedInfoList ();
595
572
void emitAssignIsolatedIntoSendingResultDiagnostics ();
596
573
void emitVerbatimErrors ();
597
574
};
@@ -2021,13 +1998,26 @@ bool SentNeverSendableDiagnosticInferrer::run() {
2021
1998
namespace {
2022
1999
2023
2000
class InOutSendingNotDisconnectedDiagnosticEmitter {
2024
- InOutSendingNotDisconnectedInfo info;
2001
+ // / The function exiting inst where the 'inout sending' parameter was actor
2002
+ // / isolated.
2003
+ TermInst *functionExitingInst;
2004
+
2005
+ // / The 'inout sending' param that we are emitting an error for.
2006
+ SILValue inoutSendingParam;
2007
+
2008
+ // / The dynamic actor isolated region info of our 'inout sending' value's
2009
+ // / region at the terminator inst.
2010
+ SILDynamicMergedIsolationInfo actorIsolatedRegionInfo;
2011
+
2025
2012
bool emittedErrorDiagnostic = false ;
2026
2013
2027
2014
public:
2028
2015
InOutSendingNotDisconnectedDiagnosticEmitter (
2029
- InOutSendingNotDisconnectedInfo info)
2030
- : info(info) {}
2016
+ TermInst *functionExitingInst, SILValue inoutSendingParam,
2017
+ SILDynamicMergedIsolationInfo actorIsolatedRegionInfo)
2018
+ : functionExitingInst(functionExitingInst),
2019
+ inoutSendingParam (inoutSendingParam),
2020
+ actorIsolatedRegionInfo(actorIsolatedRegionInfo) {}
2031
2021
2032
2022
~InOutSendingNotDisconnectedDiagnosticEmitter () {
2033
2023
// If we were supposed to emit a diagnostic and didn't emit an unknown
@@ -2036,12 +2026,10 @@ class InOutSendingNotDisconnectedDiagnosticEmitter {
2036
2026
emitUnknownPatternError ();
2037
2027
}
2038
2028
2039
- SILFunction *getFunction () const {
2040
- return info.inoutSendingParam ->getFunction ();
2041
- }
2029
+ SILFunction *getFunction () const { return inoutSendingParam->getFunction (); }
2042
2030
2043
2031
std::optional<DiagnosticBehavior> getBehaviorLimit () const {
2044
- return info. inoutSendingParam ->getType ().getConcurrencyDiagnosticBehavior (
2032
+ return inoutSendingParam->getType ().getConcurrencyDiagnosticBehavior (
2045
2033
getFunction ());
2046
2034
}
2047
2035
@@ -2051,15 +2039,15 @@ class InOutSendingNotDisconnectedDiagnosticEmitter {
2051
2039
" RegionIsolation: Aborting on unknown pattern match error" );
2052
2040
}
2053
2041
2054
- diagnoseError (info. functionExitingInst ,
2042
+ diagnoseError (functionExitingInst,
2055
2043
diag::regionbasedisolation_unknown_pattern)
2056
2044
.limitBehaviorIf (getBehaviorLimit ());
2057
2045
}
2058
2046
2059
2047
void emit ();
2060
2048
2061
2049
ASTContext &getASTContext () const {
2062
- return info. functionExitingInst ->getFunction ()->getASTContext ();
2050
+ return functionExitingInst->getFunction ()->getASTContext ();
2063
2051
}
2064
2052
2065
2053
template <typename ... T, typename ... U>
@@ -2106,7 +2094,7 @@ class InOutSendingNotDisconnectedDiagnosticEmitter {
2106
2094
void InOutSendingNotDisconnectedDiagnosticEmitter::emit () {
2107
2095
// We should always be able to find a name for an inout sending param. If we
2108
2096
// do not, emit an unknown pattern error.
2109
- auto varName = inferNameHelper (info. inoutSendingParam );
2097
+ auto varName = inferNameHelper (inoutSendingParam);
2110
2098
if (!varName) {
2111
2099
return emitUnknownPatternError ();
2112
2100
}
@@ -2115,29 +2103,22 @@ void InOutSendingNotDisconnectedDiagnosticEmitter::emit() {
2115
2103
SmallString<64 > descriptiveKindStr;
2116
2104
{
2117
2105
llvm::raw_svector_ostream os (descriptiveKindStr);
2118
- info. actorIsolatedRegionInfo .printForDiagnostics (os);
2106
+ actorIsolatedRegionInfo.printForDiagnostics (os);
2119
2107
os << ' ' ;
2120
2108
}
2121
2109
2122
2110
diagnoseError (
2123
- info. functionExitingInst ,
2111
+ functionExitingInst,
2124
2112
diag::regionbasedisolation_inout_sending_cannot_be_actor_isolated,
2125
2113
*varName, descriptiveKindStr)
2126
2114
.limitBehaviorIf (getBehaviorLimit ());
2127
2115
2128
2116
diagnoseNote (
2129
- info. functionExitingInst ,
2117
+ functionExitingInst,
2130
2118
diag::regionbasedisolation_inout_sending_cannot_be_actor_isolated_note,
2131
2119
*varName, descriptiveKindStr);
2132
2120
}
2133
2121
2134
- void TransferNonSendableImpl::emitInOutSendingNotDisconnectedInfoList () {
2135
- for (auto &info : inoutSendingNotDisconnectedInfoList) {
2136
- InOutSendingNotDisconnectedDiagnosticEmitter emitter (info);
2137
- emitter.emit ();
2138
- }
2139
- }
2140
-
2141
2122
// ===----------------------------------------------------------------------===//
2142
2123
// MARK: AssignTransferNonTransferrableIntoSendingResult
2143
2124
// ===----------------------------------------------------------------------===//
@@ -2362,12 +2343,6 @@ struct DiagnosticEvaluator final
2362
2343
// / sending operands to require insts.
2363
2344
SmallVectorImpl<PartitionOpError> &foundVerbatimErrors;
2364
2345
2365
- // / A list of state that tracks specific 'inout sending' parameters that were
2366
- // / actor isolated on function exit with the necessary state to emit the
2367
- // / error.
2368
- SmallVectorImpl<InOutSendingNotDisconnectedInfo>
2369
- &inoutSendingNotDisconnectedInfoList;
2370
-
2371
2346
// / A list of state that tracks specific 'inout sending' parameters that were
2372
2347
// / actor isolated on function exit with the necessary state to emit the
2373
2348
// / error.
@@ -2379,8 +2354,6 @@ struct DiagnosticEvaluator final
2379
2354
SmallFrozenMultiMap<Operand *, RequireInst, 8 >
2380
2355
&transferOpToRequireInstMultiMap,
2381
2356
SmallVectorImpl<PartitionOpError> &foundVerbatimErrors,
2382
- SmallVectorImpl<InOutSendingNotDisconnectedInfo>
2383
- &inoutSendingNotDisconnectedInfoList,
2384
2357
SmallVectorImpl<AssignIsolatedIntoOutSendingParameterInfo>
2385
2358
&assignIsolatedIntoOutSendingParameterInfo,
2386
2359
TransferringOperandToStateMap &operandToStateMap)
@@ -2389,8 +2362,6 @@ struct DiagnosticEvaluator final
2389
2362
info(info),
2390
2363
transferOpToRequireInstMultiMap(transferOpToRequireInstMultiMap),
2391
2364
foundVerbatimErrors(foundVerbatimErrors),
2392
- inoutSendingNotDisconnectedInfoList(
2393
- inoutSendingNotDisconnectedInfoList),
2394
2365
assignIsolatedIntoOutSendingParameterInfoList(
2395
2366
assignIsolatedIntoOutSendingParameterInfo) {}
2396
2367
@@ -2430,31 +2401,6 @@ struct DiagnosticEvaluator final
2430
2401
RequireInst::forUseAfterTransfer (partitionOp.getSourceInst ()));
2431
2402
}
2432
2403
2433
- void handleInOutSendingNotDisconnectedAtExitError (
2434
- InOutSendingNotDisconnectedAtExitError error) const {
2435
- const PartitionOp &partitionOp = *error.op ;
2436
- Element inoutSendingVal = error.inoutSendingElement ;
2437
- auto isolationRegionInfo = error.isolationInfo ;
2438
-
2439
- REGIONBASEDISOLATION_LOG (
2440
- llvm::dbgs () << " Emitting Error. Kind: InOut Sending ActorIsolated "
2441
- " at end of "
2442
- " Function Error!\n "
2443
- << " ID: %%" << inoutSendingVal << " \n "
2444
- << " Rep: "
2445
- << *info->getValueMap ().getRepresentative (inoutSendingVal)
2446
- << " Dynamic Isolation Region: " ;
2447
- isolationRegionInfo.printForOneLineLogging (llvm::dbgs ());
2448
- llvm::dbgs () << ' \n ' );
2449
- auto *self = const_cast <DiagnosticEvaluator *>(this );
2450
- auto nonTransferrableValue =
2451
- info->getValueMap ().getRepresentative (inoutSendingVal);
2452
-
2453
- self->inoutSendingNotDisconnectedInfoList .emplace_back (
2454
- partitionOp.getSourceInst (), nonTransferrableValue,
2455
- isolationRegionInfo);
2456
- }
2457
-
2458
2404
void handleAssignTransferNonTransferrableIntoSendingResult (
2459
2405
AssignNeverSendableIntoSendingResultError error) const {
2460
2406
const PartitionOp &partitionOp = *error.op ;
@@ -2517,10 +2463,10 @@ struct DiagnosticEvaluator final
2517
2463
case PartitionOpError::LocalUseAfterSend: {
2518
2464
return handleLocalUseAfterTransfer (error.getLocalUseAfterSendError ());
2519
2465
}
2520
- case PartitionOpError::SentNeverSendable: {
2466
+ case PartitionOpError::InOutSendingNotDisconnectedAtExit:
2467
+ case PartitionOpError::SentNeverSendable:
2521
2468
foundVerbatimErrors.emplace_back (error);
2522
2469
return ;
2523
- }
2524
2470
case PartitionOpError::AssignNeverSendableIntoSendingResult: {
2525
2471
return handleAssignTransferNonTransferrableIntoSendingResult (
2526
2472
error.getAssignNeverSendableIntoSendingResultError ());
@@ -2529,10 +2475,6 @@ struct DiagnosticEvaluator final
2529
2475
return handleInOutSendingNotInitializedAtExitError (
2530
2476
error.getInOutSendingNotInitializedAtExitError ());
2531
2477
}
2532
- case PartitionOpError::InOutSendingNotDisconnectedAtExit: {
2533
- return handleInOutSendingNotDisconnectedAtExitError (
2534
- error.getInOutSendingNotDisconnectedAtExitError ());
2535
- }
2536
2478
case PartitionOpError::UnknownCodePattern: {
2537
2479
return handleUnknownCodePattern (error.getUnknownCodePatternError ());
2538
2480
}
@@ -2602,8 +2544,7 @@ void TransferNonSendableImpl::runDiagnosticEvaluator() {
2602
2544
Partition workingPartition = blockState.getEntryPartition ();
2603
2545
DiagnosticEvaluator eval (
2604
2546
workingPartition, info, transferOpToRequireInstMultiMap,
2605
- foundVerbatimErrors, inoutSendingNotDisconnectedInfoList,
2606
- assignIsolatedIntoOutSendingParameterInfoList,
2547
+ foundVerbatimErrors, assignIsolatedIntoOutSendingParameterInfoList,
2607
2548
info->getTransferringOpToStateMap ());
2608
2549
2609
2550
// And then evaluate all of our partition ops on the entry partition.
@@ -2634,8 +2575,30 @@ void TransferNonSendableImpl::emitVerbatimErrors() {
2634
2575
llvm_unreachable (" Handled elsewhere" );
2635
2576
case PartitionOpError::AssignNeverSendableIntoSendingResult:
2636
2577
case PartitionOpError::InOutSendingNotInitializedAtExit:
2637
- case PartitionOpError::InOutSendingNotDisconnectedAtExit:
2638
2578
llvm_unreachable (" Not implemented yet" );
2579
+ case PartitionOpError::InOutSendingNotDisconnectedAtExit: {
2580
+ auto error = erasedError.getInOutSendingNotDisconnectedAtExitError ();
2581
+ auto inoutSendingVal =
2582
+ info->getValueMap ().getRepresentative (error.inoutSendingElement );
2583
+ auto isolationRegionInfo = error.isolationInfo ;
2584
+
2585
+ REGIONBASEDISOLATION_LOG (
2586
+ llvm::dbgs ()
2587
+ << " Emitting Error. Kind: InOut Sending ActorIsolated "
2588
+ " at end of "
2589
+ " Function Error!\n "
2590
+ << " ID: %%" << error.inoutSendingElement << " \n "
2591
+ << " Rep: " << *inoutSendingVal
2592
+ << " Dynamic Isolation Region: " ;
2593
+ isolationRegionInfo.printForOneLineLogging (llvm::dbgs ());
2594
+ llvm::dbgs () << ' \n ' );
2595
+
2596
+ InOutSendingNotDisconnectedDiagnosticEmitter emitter (
2597
+ cast<TermInst>(error.op ->getSourceInst ()), inoutSendingVal,
2598
+ isolationRegionInfo);
2599
+ emitter.emit ();
2600
+ continue ;
2601
+ }
2639
2602
case PartitionOpError::SentNeverSendable: {
2640
2603
auto e = erasedError.getSentNeverSendableError ();
2641
2604
auto errorLog = [&] {
@@ -2678,7 +2641,6 @@ void TransferNonSendableImpl::emitDiagnostics() {
2678
2641
2679
2642
runDiagnosticEvaluator ();
2680
2643
emitUseAfterTransferDiagnostics ();
2681
- emitInOutSendingNotDisconnectedInfoList ();
2682
2644
emitAssignIsolatedIntoSendingResultDiagnostics ();
2683
2645
emitVerbatimErrors ();
2684
2646
}
0 commit comments