|
17 | 17 | #include "swift/SIL/BasicBlockData.h"
|
18 | 18 | #include "swift/SIL/BasicBlockDatastructures.h"
|
19 | 19 | #include "swift/SIL/MemAccessUtils.h"
|
| 20 | +#include "swift/SIL/NodeDatastructures.h" |
20 | 21 | #include "swift/SIL/OwnershipUtils.h"
|
21 | 22 | #include "swift/SIL/SILBasicBlock.h"
|
22 | 23 | #include "swift/SIL/SILFunction.h"
|
@@ -49,10 +50,6 @@ static bool SILApplyCrossesIsolation(const SILInstruction *inst) {
|
49 | 50 | return false;
|
50 | 51 | }
|
51 | 52 |
|
52 |
| -static bool isApplyInst(SILInstruction &inst) { |
53 |
| - return ApplySite::isa(&inst) || isa<BuiltinInst>(inst); |
54 |
| -} |
55 |
| - |
56 | 53 | static AccessStorage getAccessStorageFromAddr(SILValue value) {
|
57 | 54 | assert(value->getType().isAddress());
|
58 | 55 | auto accessStorage = AccessStorage::compute(value);
|
@@ -435,13 +432,26 @@ class PartitionOpTranslator {
|
435 | 432 |
|
436 | 433 | for (auto &block : *function) {
|
437 | 434 | for (auto &inst : block) {
|
438 |
| - if (isApplyInst(inst)) { |
439 |
| - // add all nonsendable, uniquely identified arguments to applications |
440 |
| - // to capturedUIValues, because applications capture them |
| 435 | + if (auto *pai = dyn_cast<PartialApplyInst>(&inst)) { |
| 436 | + // If we find an address or a box of a non-Sendable type that is |
| 437 | + // passed to a partial_apply, mark the value's representative as being |
| 438 | + // uniquely identified and captured. |
441 | 439 | for (SILValue val : inst.getOperandValues()) {
|
442 |
| - if (val->getType().isAddress()) { |
| 440 | + if (val->getType().isAddress() && |
| 441 | + isNonSendableType(val->getType())) { |
443 | 442 | auto trackVal = getTrackableValue(val, true);
|
| 443 | + (void)trackVal; |
444 | 444 | LLVM_DEBUG(trackVal.print(llvm::dbgs()));
|
| 445 | + continue; |
| 446 | + } |
| 447 | + |
| 448 | + if (auto *pbi = dyn_cast<ProjectBoxInst>(val)) { |
| 449 | + if (isNonSendableType( |
| 450 | + pbi->getType().getSILBoxFieldType(function))) { |
| 451 | + auto trackVal = getTrackableValue(val, true); |
| 452 | + (void)trackVal; |
| 453 | + continue; |
| 454 | + } |
445 | 455 | }
|
446 | 456 | }
|
447 | 457 | }
|
|
0 commit comments