|
29 | 29 |
|
30 | 30 | using namespace swift;
|
31 | 31 |
|
32 |
| -namespace { |
33 |
| - |
34 |
| -static const char *SEP_STR = "╾──────────────────────────────╼\n"; |
| 32 | +//===----------------------------------------------------------------------===// |
| 33 | +// MARK: Utilities |
| 34 | +//===----------------------------------------------------------------------===// |
35 | 35 |
|
36 |
| -// SILApplyCrossesIsolation determines if a SIL instruction is an isolation |
37 |
| -// crossing apply expression. This is done by checking its correspondence |
38 |
| -// to an ApplyExpr AST node, and then checking the internal flags of that |
39 |
| -// AST node to see if the ActorIsolationChecker determined it crossed isolation. |
40 |
| -// It's possible this is brittle and a more nuanced check is needed, but this |
41 |
| -// suffices for all cases tested so far. |
| 36 | +/// SILApplyCrossesIsolation determines if a SIL instruction is an isolation |
| 37 | +/// crossing apply expression. This is done by checking its correspondence to an |
| 38 | +/// ApplyExpr AST node, and then checking the internal flags of that AST node to |
| 39 | +/// see if the ActorIsolationChecker determined it crossed isolation. It's |
| 40 | +/// possible this is brittle and a more nuanced check is needed, but this |
| 41 | +/// suffices for all cases tested so far. |
42 | 42 | static bool SILApplyCrossesIsolation(const SILInstruction *inst) {
|
43 | 43 | if (ApplyExpr *apply = inst->getLoc().getAsASTNode<ApplyExpr>())
|
44 | 44 | return apply->getIsolationCrossing().has_value();
|
45 | 45 |
|
46 |
| - // if the instruction doesn't correspond to an ApplyExpr, then it can't |
47 |
| - // cross an isolation domain |
| 46 | + // We assume that any instruction that does not correspond to an ApplyExpr |
| 47 | + // cannot cross an isolation domain. |
48 | 48 | return false;
|
49 | 49 | }
|
50 | 50 |
|
51 |
| -inline bool isAddress(SILValue val) { |
| 51 | +static bool isAddress(SILValue val) { |
52 | 52 | return val->getType() && val->getType().isAddress();
|
53 | 53 | }
|
54 | 54 |
|
55 |
| -inline bool isApplyInst(const SILInstruction &inst) { |
56 |
| - return isa<ApplyInst, |
57 |
| - BeginApplyInst, |
58 |
| - BuiltinInst, |
59 |
| - PartialApplyInst, |
60 |
| - TryApplyInst>(inst); |
| 55 | +static bool isApplyInst(SILInstruction &inst) { |
| 56 | + return ApplySite::isa(&inst) || isa<BuiltinInst>(inst); |
61 | 57 | }
|
62 | 58 |
|
| 59 | +//===----------------------------------------------------------------------===// |
| 60 | +// MARK: Main Computation |
| 61 | +//===----------------------------------------------------------------------===// |
| 62 | + |
| 63 | +namespace { |
| 64 | + |
| 65 | +static const char *SEP_STR = "╾──────────────────────────────╼\n"; |
| 66 | + |
63 | 67 | using TrackableValueID = PartitionPrimitives::Element;
|
64 | 68 | using Region = PartitionPrimitives::Region;
|
65 | 69 |
|
@@ -201,8 +205,8 @@ class PartitionOpTranslator {
|
201 | 205 | std::set<TrackableSILValue> capturedUIValues;
|
202 | 206 |
|
203 | 207 | void initCapturedUIValues() {
|
204 |
| - for (const SILBasicBlock &block: *function) { |
205 |
| - for (const SILInstruction &inst: block) { |
| 208 | + for (auto &block : *function) { |
| 209 | + for (auto &inst : block) { |
206 | 210 | if (isApplyInst(inst)) {
|
207 | 211 | // add all nonsendable, uniquely identified arguments to applications
|
208 | 212 | // to capturedUIValues, because applications capture them
|
|
0 commit comments