@@ -339,7 +339,7 @@ class PartitionOpTranslator {
339
339
std::vector<TrackableValueID> neverTransferredValueIDs;
340
340
341
341
// / A cache of argument IDs.
342
- SmallVector<TrackableValueID> argIDs ;
342
+ std::optional<Partition> functionArgPartition ;
343
343
344
344
// / A builder struct that we use to convert individual instructions into lists
345
345
// / of PartitionOps.
@@ -523,35 +523,39 @@ class PartitionOpTranslator {
523
523
524
524
// ===========================================================================
525
525
526
- // / Get the vector of IDs corresponding to the arguments to the underlying
527
- // / function, and the self parameter if there is one.
528
- ArrayRef<TrackableValueID> getArgIDs () const {
529
- auto functionArguments = function->getArguments ();
530
- if (functionArguments.empty ())
531
- return {};
532
-
533
- // If we have arguments and argIDs is empty, then we need to initialize our
534
- // lazy array.
535
- if (argIDs.empty ()) {
536
- auto *self = const_cast <PartitionOpTranslator *>(this );
537
- for (SILArgument *arg : functionArguments) {
538
- if (auto state = trackIfNonSendable (arg)) {
539
- self->neverTransferredValueIDs .push_back (state->getID ());
540
- self->argIDs .push_back (state->getID ());
541
- }
542
- }
543
- }
544
-
545
- return argIDs;
546
- }
547
-
548
526
public:
549
527
// Create a partition that places all arguments from this function,
550
528
// including self if available, into the same region, ensuring those
551
529
// arguments get IDs in doing so. This Partition will be used as the
552
530
// entry point for the full partition analysis.
553
- Partition getEntryPartition () {
554
- return Partition::singleRegion (getArgIDs ());
531
+ Partition getEntryPartition () const {
532
+ if (!functionArgPartition) {
533
+ LLVM_DEBUG (llvm::dbgs () << " Initializing Function Args:\n " );
534
+ auto *self = const_cast <PartitionOpTranslator *>(this );
535
+ auto functionArguments = function->getArguments ();
536
+ if (functionArguments.empty ()) {
537
+ LLVM_DEBUG (llvm::dbgs () << " None.\n " );
538
+ self->functionArgPartition = Partition::singleRegion ({});
539
+ } else {
540
+ llvm::SmallVector<Element, 8 > nonSendableIndices;
541
+ for (SILArgument *arg : functionArguments) {
542
+ if (auto state = tryToTrackValue (arg)) {
543
+ // If we have an arg that is an actor, we allow for it to be
544
+ // consumed... value ids derived from it though cannot be consumed.
545
+ LLVM_DEBUG (llvm::dbgs () << " %%" << state->getID ());
546
+ self->neverTransferredValueIDs .push_back (state->getID ());
547
+ nonSendableIndices.push_back (state->getID ());
548
+ LLVM_DEBUG (llvm::dbgs () << *arg);
549
+ }
550
+ }
551
+
552
+ // All non actor values are in the same partition.
553
+ self->functionArgPartition =
554
+ Partition::singleRegion (nonSendableIndices);
555
+ }
556
+ }
557
+
558
+ return *functionArgPartition;
555
559
}
556
560
557
561
// Get the vector of IDs that cannot be legally transferred at any point in
0 commit comments