Skip to content

Commit 2503384

Browse files
authored
Merge pull request #77370 from gottesmm/transfer_to_send
[region-isolation] Excise 'transfer' in favor of 'sending'
2 parents 3efa770 + 32b4de6 commit 2503384

18 files changed

+643
-692
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -963,28 +963,28 @@ NOTE(regionbasedisolation_type_is_non_sendable, none,
963963
//===
964964
// Use After Send Emitter
965965

966-
ERROR(regionbasedisolation_named_transfer_yields_race, none,
966+
ERROR(regionbasedisolation_named_send_yields_race, none,
967967
"sending %0 risks causing data races",
968968
(Identifier))
969-
ERROR(regionbasedisolation_type_transfer_yields_race, none,
969+
ERROR(regionbasedisolation_type_send_yields_race, none,
970970
"sending value of non-Sendable type %0 risks causing data races",
971971
(Type))
972-
NOTE(regionbasedisolation_type_use_after_transfer, none,
972+
NOTE(regionbasedisolation_type_use_after_send, none,
973973
"sending value of non-Sendable type %0 to %1 callee risks causing data races between %1 and local %2 uses",
974974
(Type, ActorIsolation, ActorIsolation))
975-
NOTE(regionbasedisolation_type_use_after_transfer_callee, none,
975+
NOTE(regionbasedisolation_type_use_after_send_callee, none,
976976
"sending value of non-Sendable type %0 to %1 %2 %3 risks causing data "
977977
"races between %1 and local %4 uses",
978978
(Type, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
979979

980-
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,
980+
NOTE(regionbasedisolation_named_info_send_yields_race, none,
981981
"sending %1%0 to %2 callee risks causing data races between %2 and local %3 uses",
982982
(Identifier, StringRef, ActorIsolation, ActorIsolation))
983-
NOTE(regionbasedisolation_named_info_transfer_yields_race_callee, none,
983+
NOTE(regionbasedisolation_named_info_send_yields_race_callee, none,
984984
"sending %1%0 to %2 %3 %4 risks causing data races between %2 and local %5 uses",
985985
(Identifier, StringRef, ActorIsolation, DescriptiveDeclKind, DeclName, ActorIsolation))
986986

987-
// Use after transfer closure.
987+
// Use after send closure.
988988
NOTE(regionbasedisolation_type_isolated_capture_yields_race, none,
989989
"sending value of non-Sendable type %0 to %1 closure due to closure capture risks causing races in between %1 and %2 uses",
990990
(Type, ActorIsolation, ActorIsolation))
@@ -1011,18 +1011,18 @@ NOTE(regionbasedisolation_typed_use_after_sending_callee, none,
10111011
//===
10121012
// Sending Never Sendable Emitter
10131013

1014-
NOTE(regionbasedisolation_named_transfer_non_transferrable, none,
1014+
NOTE(regionbasedisolation_named_send_never_sendable, none,
10151015
"sending %1%0 to %2 callee risks causing data races between %2 and %3 uses",
10161016
(Identifier, StringRef, ActorIsolation, StringRef))
1017-
NOTE(regionbasedisolation_named_transfer_non_transferrable_callee, none,
1017+
NOTE(regionbasedisolation_named_send_never_sendable_callee, none,
10181018
"sending %1%0 to %2 %3 %4 risks causing data races between %2 and %5 uses",
10191019
(Identifier, StringRef, ActorIsolation, DescriptiveDeclKind, DeclName, StringRef))
10201020

1021-
NOTE(regionbasedisolation_named_transfer_into_sending_param, none,
1021+
NOTE(regionbasedisolation_named_send_into_sending_param, none,
10221022
"%0%1 is passed as a 'sending' parameter; Uses in callee may race with "
10231023
"later %0uses",
10241024
(StringRef, Identifier))
1025-
NOTE(regionbasedisolation_named_notransfer_transfer_into_result, none,
1025+
NOTE(regionbasedisolation_named_nosend_send_into_result, none,
10261026
"%0%1 cannot be a 'sending' result. %2 uses may race with caller uses",
10271027
(StringRef, Identifier, StringRef))
10281028
NOTE(regionbasedisolation_typed_tns_passed_to_sending, none,
@@ -1054,19 +1054,19 @@ NOTE(regionbasedisolation_typed_tns_passed_to_sending_callee, none,
10541054
"Passing %0 value of non-Sendable type %1 as a 'sending' parameter to %2 %3 risks causing races inbetween %0 uses and uses reachable from %3",
10551055
(StringRef, Type, DescriptiveDeclKind, DeclName))
10561056

1057-
NOTE(regionbasedisolation_named_transfer_nt_asynclet_capture, none,
1057+
NOTE(regionbasedisolation_named_send_nt_asynclet_capture, none,
10581058
"sending %1 %0 into async let risks causing data races between nonisolated and %1 uses",
10591059
(Identifier, StringRef))
1060-
NOTE(regionbasedisolation_typed_transferneversendable_via_arg, none,
1060+
NOTE(regionbasedisolation_typed_sendneversendable_via_arg, none,
10611061
"sending %0 value of non-Sendable type %1 to %2 callee risks causing races in between %0 and %2 uses",
10621062
(StringRef, Type, ActorIsolation))
1063-
NOTE(regionbasedisolation_typed_transferneversendable_via_arg_callee, none,
1063+
NOTE(regionbasedisolation_typed_sendneversendable_via_arg_callee, none,
10641064
"sending %0 value of non-Sendable type %1 to %2 %3 %4 risks causing races in between %0 and %2 uses",
10651065
(StringRef, Type, ActorIsolation, DescriptiveDeclKind, DeclName))
10661066

10671067
// Error that is only used when the send non sendable emitter cannot discover any
10681068
// information to give a better diagnostic.
1069-
ERROR(regionbasedisolation_task_or_actor_isolated_transferred, none,
1069+
ERROR(regionbasedisolation_task_or_actor_isolated_sent, none,
10701070
"task or actor isolated value cannot be sent", ())
10711071

10721072
//===

include/swift/SILOptimizer/Analysis/RegionAnalysis.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static inline bool shouldAbortOnUnknownPatternMatchError() {
3636
return AbortOnUnknownPatternMatchError;
3737
}
3838

39-
using TransferringOperandSetFactory = Partition::TransferringOperandSetFactory;
39+
using SendingOperandSetFactory = Partition::SendingOperandSetFactory;
4040
using Element = PartitionPrimitives::Element;
4141
using Region = PartitionPrimitives::Region;
4242

@@ -74,15 +74,15 @@ class BlockPartitionState {
7474
/// block.
7575
std::vector<PartitionOp> blockPartitionOps = {};
7676

77-
TransferringOperandSetFactory &ptrSetFactory;
77+
SendingOperandSetFactory &ptrSetFactory;
7878

79-
TransferringOperandToStateMap &transferringOpToStateMap;
79+
SendingOperandToStateMap &sendingOpToStateMap;
8080

8181
BlockPartitionState(SILBasicBlock *basicBlock,
8282
PartitionOpTranslator &translator,
83-
TransferringOperandSetFactory &ptrSetFactory,
83+
SendingOperandSetFactory &ptrSetFactory,
8484
IsolationHistory::Factory &isolationHistoryFactory,
85-
TransferringOperandToStateMap &transferringOpToStateMap);
85+
SendingOperandToStateMap &sendingOpToStateMap);
8686

8787
public:
8888
bool getLiveness() const { return isLive; }
@@ -359,8 +359,7 @@ class RegionAnalysisValueMap {
359359
class RegionAnalysisFunctionInfo {
360360
using BlockPartitionState = regionanalysisimpl::BlockPartitionState;
361361
using PartitionOpTranslator = regionanalysisimpl::PartitionOpTranslator;
362-
using TransferringOperandSetFactory =
363-
regionanalysisimpl::TransferringOperandSetFactory;
362+
using SendingOperandSetFactory = regionanalysisimpl::SendingOperandSetFactory;
364363
using BasicBlockData = BasicBlockData<BlockPartitionState>;
365364

366365
llvm::BumpPtrAllocator allocator;
@@ -373,11 +372,11 @@ class RegionAnalysisFunctionInfo {
373372
// allocator when we allocate everything.
374373
PartitionOpTranslator *translator;
375374

376-
TransferringOperandSetFactory ptrSetFactory;
375+
SendingOperandSetFactory ptrSetFactory;
377376

378377
IsolationHistory::Factory isolationHistoryFactory;
379378

380-
TransferringOperandToStateMap transferringOpToStateMap;
379+
SendingOperandToStateMap sendingOperandToStateMap;
381380

382381
// We make this optional to prevent an issue that we have seen on windows when
383382
// capturing a field in a closure that is used to initialize a different
@@ -464,7 +463,7 @@ class RegionAnalysisFunctionInfo {
464463
reverse_range getReverseRange() { return {rbegin(), rend()}; }
465464
const_reverse_range getReverseRange() const { return {rbegin(), rend()}; }
466465

467-
TransferringOperandSetFactory &getOperandSetFactory() {
466+
SendingOperandSetFactory &getOperandSetFactory() {
468467
assert(supportedFunction && "Unsupported Function?!");
469468
return ptrSetFactory;
470469
}
@@ -479,9 +478,9 @@ class RegionAnalysisFunctionInfo {
479478
return isolationHistoryFactory;
480479
}
481480

482-
TransferringOperandToStateMap &getTransferringOpToStateMap() {
481+
SendingOperandToStateMap &getSendingOperandToStateMap() {
483482
assert(supportedFunction && "Unsupported Function?!");
484-
return transferringOpToStateMap;
483+
return sendingOperandToStateMap;
485484
}
486485

487486
bool isClosureCaptured(SILValue value, Operand *op);

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ PASS(TempRValueOpt, "temp-rvalue-opt",
387387
"Remove short-lived immutable temporary copies")
388388
PASS(IRGenPrepare, "irgen-prepare",
389389
"Cleanup SIL in preparation for IRGen")
390-
PASS(TransferNonSendable, "transfer-non-sendable",
390+
PASS(SendNonSendable, "send-non-sendable",
391391
"Checks calls that send non-sendable values between isolation domains")
392392
PASS(LowerTupleAddrConstructor, "lower-tuple-addr-constructor",
393393
"Lower tuple addr constructor to tuple_element_addr+copy_addr")

include/swift/SILOptimizer/Utils/PartitionOpError.def

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
///
3030
/// 2. The element in the PartitionOp that was asked to be alive.
3131
///
32-
/// 3. The operand of the instruction that originally transferred the
33-
/// region. Can be used to get the immediate value transferred or the
34-
/// transferring instruction.
32+
/// 3. The operand of the instruction that originally sent the region. Can be
33+
/// used to get the immediate value sent or the sending instruction.
3534
PARTITION_OP_ERROR(LocalUseAfterSend)
3635

3736
/// This is called if we detect a never sendable element that was actually sent.

0 commit comments

Comments
 (0)