@@ -527,94 +527,3 @@ void swift::findClosuresForFunctionValue(
527
527
// Ignore other unrecognized values that feed this applied argument.
528
528
}
529
529
}
530
-
531
- namespace {
532
-
533
- enum class OwnershipQualifiedKind {
534
- NotApplicable,
535
- Qualified,
536
- Unqualified,
537
- };
538
-
539
- struct OwnershipQualifiedKindVisitor : SILInstructionVisitor<OwnershipQualifiedKindVisitor, OwnershipQualifiedKind> {
540
-
541
- OwnershipQualifiedKind visitSILInstruction (SILInstruction *I) {
542
- return OwnershipQualifiedKind::NotApplicable;
543
- }
544
-
545
- #define QUALIFIED_INST (CLASS ) \
546
- OwnershipQualifiedKind visit ## CLASS(CLASS *I) { \
547
- return OwnershipQualifiedKind::Qualified; \
548
- }
549
- QUALIFIED_INST (EndBorrowInst)
550
- QUALIFIED_INST (LoadBorrowInst)
551
- QUALIFIED_INST (CopyValueInst)
552
- QUALIFIED_INST (DestroyValueInst)
553
- #define ALWAYS_OR_SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
554
- QUALIFIED_INST (Copy##Name##ValueInst)
555
- #include " swift/AST/ReferenceStorage.def"
556
- #undef QUALIFIED_INST
557
-
558
- OwnershipQualifiedKind visitLoadInst (LoadInst *LI) {
559
- if (LI->getOwnershipQualifier () == LoadOwnershipQualifier::Unqualified)
560
- return OwnershipQualifiedKind::Unqualified;
561
- return OwnershipQualifiedKind::Qualified;
562
- }
563
-
564
- OwnershipQualifiedKind visitStoreInst (StoreInst *SI) {
565
- if (SI->getOwnershipQualifier () == StoreOwnershipQualifier::Unqualified)
566
- return OwnershipQualifiedKind::Unqualified;
567
- return OwnershipQualifiedKind::Qualified;
568
- }
569
- };
570
-
571
- } // end anonymous namespace
572
-
573
- bool FunctionOwnershipEvaluator::evaluate (SILInstruction *I) {
574
- assert (I->getFunction () == F.get () && " Can not evaluate function ownership "
575
- " implications of an instruction that "
576
- " does not belong to the instruction "
577
- " that we are evaluating" );
578
-
579
- switch (OwnershipQualifiedKindVisitor ().visit (I)) {
580
- case OwnershipQualifiedKind::Unqualified: {
581
- // If we already know that the function has unqualified ownership, just
582
- // return early.
583
- if (!F.get ()->hasOwnership ())
584
- return true ;
585
-
586
- // Ok, so we know at this point that we have qualified ownership. If we have
587
- // seen any instructions with qualified ownership, we have an error since
588
- // the function mixes qualified and unqualified instructions.
589
- if (HasOwnershipQualifiedInstruction)
590
- return false ;
591
-
592
- // Otherwise, set the function to have unqualified ownership. This will
593
- // ensure that no more Qualified instructions can be added to the given
594
- // function.
595
- F.get ()->setOwnershipEliminated ();
596
- return true ;
597
- }
598
- case OwnershipQualifiedKind::Qualified: {
599
- // First check if our function has unqualified ownership. If we already do
600
- // have unqualified ownership, then we know that we have already seen an
601
- // unqualified ownership instruction. This means the function has both
602
- // qualified and unqualified instructions. =><=.
603
- if (!F.get ()->hasOwnership ())
604
- return false ;
605
-
606
- // Ok, at this point we know that we are still qualified. Since functions
607
- // start as qualified, we need to set the HasOwnershipQualifiedInstructions
608
- // so we do not need to look back through the function if we see an
609
- // unqualified instruction later on.
610
- HasOwnershipQualifiedInstruction = true ;
611
- return true ;
612
- }
613
- case OwnershipQualifiedKind::NotApplicable: {
614
- // Not Applicable instr
615
- return true ;
616
- }
617
- }
618
-
619
- llvm_unreachable (" Unhandled OwnershipQualifiedKind in switch." );
620
- }
0 commit comments