@@ -400,7 +400,8 @@ bool MoveKillsCopyableValuesChecker::check() {
400
400
SmallSetVector<SILValue, 32 > valuesToCheck;
401
401
402
402
for (auto *arg : fn->getEntryBlock ()->getSILFunctionArguments ()) {
403
- if (arg->getOwnershipKind () == OwnershipKind::Owned) {
403
+ if (arg->getOwnershipKind () == OwnershipKind::Owned &&
404
+ !arg->getType ().isMoveOnly ()) {
404
405
LLVM_DEBUG (llvm::dbgs () << " Found owned arg to check: " << *arg);
405
406
valuesToCheck.insert (arg);
406
407
}
@@ -409,7 +410,7 @@ bool MoveKillsCopyableValuesChecker::check() {
409
410
for (auto &block : *fn) {
410
411
for (auto &ii : block) {
411
412
if (auto *bbi = dyn_cast<BeginBorrowInst>(&ii)) {
412
- if (bbi->isLexical ()) {
413
+ if (bbi->isLexical () && !bbi-> getType (). isMoveOnly () ) {
413
414
LLVM_DEBUG (llvm::dbgs ()
414
415
<< " Found lexical lifetime to check: " << *bbi);
415
416
valuesToCheck.insert (bbi);
@@ -551,19 +552,28 @@ class MoveKillsCopyableValuesCheckerPass : public SILFunctionTransform {
551
552
SILAnalysis::InvalidationKind::BranchesAndInstructions);
552
553
}
553
554
554
- // Now search through our function one last time and any move_value
555
- // [allows_diagnostics] that remain are ones that we did not know how to
556
- // check so emit a diagnostic so the user doesn't assume that they have
557
- // guarantees.
555
+ // Now search through our function one last time and:
556
+ //
557
+ // 1. Given any move_value on a move only type, just unset the allows
558
+ // diagnostics flag. The move checker will have emitted any errors caused
559
+ // by our move [allows_diagnostic] earlier in the compilation pipeline.
560
+ //
561
+ // 2. Any move_value [allows_diagnostics] that remain that are not on a move
562
+ // only type are ones that we did not know how to check so emit a
563
+ // diagnostic so the user doesn't assume that they have guarantees.
558
564
//
559
565
// TODO: Emit specific diagnostics here (e.x.: _move of global).
560
- if (DisableUnhandledMoveDiagnostic)
561
- return ;
562
566
for (auto &block : *fn) {
563
567
for (auto &inst : block) {
564
568
if (auto *mvi = dyn_cast<MoveValueInst>(&inst)) {
565
569
if (mvi->getAllowDiagnostics ()) {
566
- emitUnsupportedUseCaseError (mvi);
570
+ if (mvi->getType ().isMoveOnly ()) {
571
+ mvi->setAllowsDiagnostics (false );
572
+ continue ;
573
+ }
574
+
575
+ if (!DisableUnhandledMoveDiagnostic)
576
+ emitUnsupportedUseCaseError (mvi);
567
577
}
568
578
}
569
579
}
0 commit comments