Skip to content

Commit 0bad8f9

Browse files
committed
[region-isolation] Rename SendNonSendable.cpp -> TransferNonSendable.cpp.
1 parent ff6ee74 commit 0bad8f9

File tree

102 files changed

+448
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+448
-447
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ EXPERIMENTAL_FEATURE(BuiltinModule, true)
219219
EXPERIMENTAL_FEATURE(StrictConcurrency, true)
220220

221221
/// Defer Sendable checking to SIL diagnostic phase.
222-
EXPERIMENTAL_FEATURE(SendNonSendable, false)
222+
EXPERIMENTAL_FEATURE(TransferNonSendable, false)
223223

224224
/// Within strict concurrency, narrow global variable isolation requirements.
225225
EXPERIMENTAL_FEATURE(GlobalConcurrency, false)

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ PASS(TempRValueOpt, "temp-rvalue-opt",
367367
"Remove short-lived immutable temporary copies")
368368
PASS(IRGenPrepare, "irgen-prepare",
369369
"Cleanup SIL in preparation for IRGen")
370-
PASS(SendNonSendable, "send-non-sendable",
370+
PASS(TransferNonSendable, "transfer-non-sendable",
371371
"Checks calls that send non-sendable values between isolation domains")
372372
PASS(SILGenCleanup, "silgen-cleanup",
373373
"Cleanup SIL in preparation for diagnostics")

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "llvm/Support/Debug.h"
2121
#include <algorithm>
2222

23-
#define DEBUG_TYPE "send-non-sendable"
23+
#define DEBUG_TYPE "transfer-non-sendable"
2424

2525
namespace swift {
2626

@@ -91,7 +91,7 @@ enum class PartitionOpKind : uint8_t {
9191
};
9292

9393
// PartitionOp represents a primitive operation that can be performed on
94-
// Partitions. This is part of the SendNonSendable SIL pass workflow:
94+
// Partitions. This is part of the TransferNonSendable SIL pass workflow:
9595
// first SILBasicBlocks are compiled to vectors of PartitionOps, then a fixed
9696
// point partition is found over the CFG.
9797
class PartitionOp {

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,9 +3569,7 @@ static bool usesFeatureParameterPacks(Decl *decl) {
35693569
return false;
35703570
}
35713571

3572-
static bool usesFeatureSendNonSendable(Decl *decl) {
3573-
return false;
3574-
}
3572+
static bool usesFeatureTransferNonSendable(Decl *decl) { return false; }
35753573

35763574
static bool usesFeatureGlobalConcurrency(Decl *decl) { return false; }
35773575

lib/SILOptimizer/Mandatory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target_sources(swiftSILOptimizer PRIVATE
4242
PMOMemoryUseCollector.cpp
4343
RawSILInstLowering.cpp
4444
ReferenceBindingTransform.cpp
45-
SendNonSendable.cpp
45+
TransferNonSendable.cpp
4646
SILGenCleanup.cpp
4747
YieldOnceCheck.cpp
4848
OSLogOptimization.cpp

lib/SILOptimizer/Mandatory/SendNonSendable.cpp renamed to lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- SendNonSendable.cpp ----------------------------------------------===//
1+
//===--- TransferNonSendable.cpp ------------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -27,7 +27,7 @@
2727
#include "llvm/ADT/DenseMap.h"
2828
#include "llvm/Support/Debug.h"
2929

30-
#define DEBUG_TYPE "send-non-sendable"
30+
#define DEBUG_TYPE "transfer-non-sendable"
3131

3232
using namespace swift;
3333

@@ -709,7 +709,8 @@ class PartitionOpTranslator {
709709
if (auto cast = dyn_cast<TryApplyInst>(applyInst))
710710
return translateIsolationCrossingSILApply(cast);
711711

712-
llvm_unreachable("Only ApplyInst, BeginApplyInst, and TryApplyInst should cross isolation domains");
712+
llvm_unreachable("Only ApplyInst, BeginApplyInst, and TryApplyInst should "
713+
"cross isolation domains");
713714
}
714715

715716
// handles the semantics for SIL applies that cross isolation
@@ -731,7 +732,8 @@ class PartitionOpTranslator {
731732

732733
auto getSourceSelf = [&]() {
733734
if (auto callExpr = dyn_cast<CallExpr>(sourceApply))
734-
if (auto calledExpr = dyn_cast<DotSyntaxCallExpr>(callExpr->getDirectCallee()))
735+
if (auto calledExpr =
736+
dyn_cast<DotSyntaxCallExpr>(callExpr->getDirectCallee()))
735737
return calledExpr->getBase();
736738
return (Expr *)nullptr;
737739
};
@@ -814,7 +816,7 @@ class PartitionOpTranslator {
814816
// an enum select is just a multi assign
815817
void translateSILSelectEnum(SelectEnumOperation selectEnumInst) {
816818
SmallVector<SILValue, 8> enumOperands;
817-
for (unsigned i = 0; i < selectEnumInst.getNumCases(); i ++)
819+
for (unsigned i = 0; i < selectEnumInst.getNumCases(); i++)
818820
enumOperands.push_back(selectEnumInst.getCase(i).second);
819821
if (selectEnumInst.hasDefault())
820822
enumOperands.push_back(selectEnumInst.getDefaultResult());
@@ -829,8 +831,8 @@ class PartitionOpTranslator {
829831
for (unsigned i = 0; i < switchEnumInst->getNumCases(); i++) {
830832
SILBasicBlock *dest = switchEnumInst->getCase(i).second;
831833
if (dest->getNumArguments() > 0) {
832-
assert(dest->getNumArguments() == 1
833-
&& "expected at most one bb arg in dest of enum switch");
834+
assert(dest->getNumArguments() == 1 &&
835+
"expected at most one bb arg in dest of enum switch");
834836
argSources.addValues({switchEnumInst->getOperand()}, dest);
835837
}
836838
}
@@ -992,7 +994,8 @@ class PartitionOpTranslator {
992994
// argument passing
993995
case SILInstructionKind::BranchInst: {
994996
auto *branchInst = cast<BranchInst>(inst);
995-
assert(branchInst->getNumArgs() == branchInst->getDestBB()->getNumArguments());
997+
assert(branchInst->getNumArgs() ==
998+
branchInst->getDestBB()->getNumArguments());
996999
TermArgSources argSources;
9971000
argSources.addValues(branchInst->getArgs(), branchInst->getDestBB());
9981001
return translateSILPhi(argSources);
@@ -1256,18 +1259,16 @@ class BlockPartitionState {
12561259
public:
12571260
// run the passed action on each partitionOp in this block. Action should
12581261
// return true iff iteration should continue
1259-
void forEachPartitionOp(llvm::function_ref<bool (const PartitionOp&)> action) const {
1262+
void forEachPartitionOp(
1263+
llvm::function_ref<bool(const PartitionOp &)> action) const {
12601264
for (const PartitionOp &partitionOp : blockPartitionOps)
1261-
if (!action(partitionOp)) break;
1265+
if (!action(partitionOp))
1266+
break;
12621267
}
12631268

1264-
const Partition& getEntryPartition() const {
1265-
return entryPartition;
1266-
}
1269+
const Partition &getEntryPartition() const { return entryPartition; }
12671270

1268-
const Partition& getExitPartition() const {
1269-
return exitPartition;
1270-
}
1271+
const Partition &getExitPartition() const { return exitPartition; }
12711272

12721273
SWIFT_DEBUG_DUMP { print(llvm::dbgs()); }
12731274

@@ -1352,7 +1353,7 @@ class TransferredReason {
13521353

13531354
friend class TransferRequireAccumulator;
13541355

1355-
bool containsOp(const PartitionOp& op) {
1356+
bool containsOp(const PartitionOp &op) {
13561357
return llvm::any_of(transferOps,
13571358
[&](const std::pair<unsigned, PartitionOp> &pair) {
13581359
return pair.second == op;
@@ -1404,7 +1405,7 @@ class TransferRequireAccumulator {
14041405
PartitionOpAtDistance(PartitionOp partitionOp, unsigned distance)
14051406
: partitionOp(partitionOp), distance(distance) {}
14061407

1407-
bool operator<(const PartitionOpAtDistance& other) const {
1408+
bool operator<(const PartitionOpAtDistance &other) const {
14081409
if (distance != other.distance)
14091410
return distance < other.distance;
14101411
return partitionOp < other.partitionOp;
@@ -1516,7 +1517,7 @@ class TransferRequireAccumulator {
15161517
// and traces those facts to the Transfer operations that could have been
15171518
// responsible.
15181519
class RaceTracer {
1519-
const BasicBlockData<BlockPartitionState>& blockStates;
1520+
const BasicBlockData<BlockPartitionState> &blockStates;
15201521

15211522
std::map<std::pair<SILBasicBlock *, TrackableValueID>, TransferredReason>
15221523
transferredAtEntryReasons;
@@ -1596,7 +1597,8 @@ class RaceTracer {
15961597
for (SILBasicBlock *pred : SILBlock->getPredecessorBlocks())
15971598
for (std::vector<TrackableValueID> region :
15981599
blockStates[pred].getExitPartition().getNonTransferredRegions()) {
1599-
for (TrackableValueID fst : region) for (TrackableValueID snd : region)
1600+
for (TrackableValueID fst : region)
1601+
for (TrackableValueID snd : region)
16001602
if (fst != snd && entryTracks(fst) && entryTracks(snd))
16011603
singleStepJoins[fst].insert(snd);
16021604
}
@@ -1668,9 +1670,9 @@ class RaceTracer {
16681670
workingPartition.apply(PartitionOp::AssignFresh(transferredVal));
16691671

16701672
int i = 0;
1671-
block.forEachPartitionOp([&](const PartitionOp& partitionOp) {
1673+
block.forEachPartitionOp([&](const PartitionOp &partitionOp) {
16721674
if (targetOp == partitionOp)
1673-
return false; //break
1675+
return false; // break
16741676
workingPartition.apply(partitionOp);
16751677
if (workingPartition.isTransferred(transferredVal) &&
16761678
!transferredReason) {
@@ -1880,7 +1882,8 @@ class PartitionAnalysis {
18801882
if (auto castExpr = dyn_cast<ImplicitConversionExpr>(expr))
18811883
return hasBeenEmitted(castExpr->getSubExpr());
18821884

1883-
if (emittedExprs.contains(expr)) return true;
1885+
if (emittedExprs.contains(expr))
1886+
return true;
18841887
emittedExprs.insert(expr);
18851888
return false;
18861889
}
@@ -1891,9 +1894,8 @@ class PartitionAnalysis {
18911894
void diagnose() {
18921895
assert(solved && "diagnose should not be called before solve");
18931896

1894-
LLVM_DEBUG(
1895-
llvm::dbgs() << "Emitting diagnostics for function "
1896-
<< function->getName() << "\n");
1897+
LLVM_DEBUG(llvm::dbgs() << "Emitting diagnostics for function "
1898+
<< function->getName() << "\n");
18971899
RaceTracer tracer(function, blockStates);
18981900

18991901
for (auto [block, blockState] : blockStates) {
@@ -1960,7 +1962,8 @@ class PartitionAnalysis {
19601962
}
19611963
auto argExpr = transferOp.getSourceExpr();
19621964
if (!argExpr)
1963-
assert(false && "sourceExpr should be populated for ApplyExpr consumptions");
1965+
assert(false &&
1966+
"sourceExpr should be populated for ApplyExpr consumptions");
19641967

19651968
function->getASTContext()
19661969
.Diags
@@ -2003,14 +2006,14 @@ namespace {
20032006
// this class is the entry point to the region-based Sendable analysis,
20042007
// after certain checks are performed to ensure the analysis can be completed
20052008
// a PartitionAnalysis object is created and used to run the analysis.
2006-
class SendNonSendable : public SILFunctionTransform {
2009+
class TransferNonSendable : public SILFunctionTransform {
20072010
// find any ApplyExprs in this function, and check if any of them make an
20082011
// unsatisfied isolation jump, emitting appropriate diagnostics if so
20092012
void run() override {
20102013
SILFunction *function = getFunction();
20112014

20122015
if (!function->getASTContext().LangOpts.hasFeature(
2013-
Feature::SendNonSendable))
2016+
Feature::TransferNonSendable))
20142017
return;
20152018

20162019
LLVM_DEBUG(llvm::dbgs()
@@ -2024,9 +2027,9 @@ class SendNonSendable : public SILFunctionTransform {
20242027
return;
20252028
}
20262029

2027-
// The sendable protocol should /always/ be available if SendNonSendable is
2028-
// enabled. If not, there is a major bug in the compiler and we should fail
2029-
// loudly.
2030+
// The sendable protocol should /always/ be available if TransferNonSendable
2031+
// is enabled. If not, there is a major bug in the compiler and we should
2032+
// fail loudly.
20302033
if (!function->getASTContext().getProtocol(KnownProtocolKind::Sendable))
20312034
llvm::report_fatal_error("Sendable protocol not available!");
20322035

@@ -2038,6 +2041,6 @@ class SendNonSendable : public SILFunctionTransform {
20382041

20392042
/// This pass is known to depend on the following passes having run before it:
20402043
/// none so far.
2041-
SILTransform *swift::createSendNonSendable() {
2042-
return new SendNonSendable();
2044+
SILTransform *swift::createTransferNonSendable() {
2045+
return new TransferNonSendable();
20432046
}

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
133133
P.addAddressLowering();
134134

135135
P.addFlowIsolation();
136-
P.addSendNonSendable();
136+
P.addTransferNonSendable();
137137

138138
// Automatic differentiation: canonicalize all differentiability witnesses
139139
// and `differentiable_function` instructions.

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3182,7 +3182,7 @@ namespace {
31823182

31833183
// check if language features ask us to defer sendable diagnostics
31843184
// if so, don't check for sendability of arguments here
3185-
if (!ctx.LangOpts.hasFeature(Feature::SendNonSendable)) {
3185+
if (!ctx.LangOpts.hasFeature(Feature::TransferNonSendable)) {
31863186
diagnoseApplyArgSendability(apply, getDeclContext());
31873187
}
31883188

test/Concurrency/LLDBDebuggerFunctionActorExtension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify
22
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
33
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
4-
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable
4+
// RUN: %target-swift-frontend -disable-availability-checking -debugger-support %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature TransferNonSendable
55

66
// REQUIRES: concurrency
77
// REQUIRES: asserts

test/Concurrency/actor_call_implicitly_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -parse-as-library %s -emit-sil -o /dev/null -verify -verify-additional-prefix complete-
2-
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -parse-as-library %s -emit-sil -o /dev/null -verify -enable-experimental-feature SendNonSendable
2+
// RUN: %target-swift-frontend -disable-availability-checking -warn-concurrency -parse-as-library %s -emit-sil -o /dev/null -verify -enable-experimental-feature TransferNonSendable
33

44
// REQUIRES: concurrency
55
// REQUIRES: asserts

0 commit comments

Comments
 (0)