Skip to content

Commit 050f5bd

Browse files
authored
Merge pull request #61827 from gottesmm/pr-f1f6eaf5572368435fde66d57e50fcba73698fd8
[move-only] Emit a "checker did not understand" error if copy propagation fails for some reason.
2 parents 2bab74c + 9de036d commit 050f5bd

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyObjectChecker.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,24 @@ bool MoveOnlyChecker::check(NonLocalAccessBlockAnalysis *accessBlockAnalysis,
418418
LLVM_DEBUG(llvm::dbgs() << "Visiting: " << *markedValue);
419419

420420
// First canonicalize ownership.
421-
changed |= canonicalizer.canonicalizeValueLifetime(markedValue);
421+
if (!canonicalizer.canonicalizeValueLifetime(markedValue)) {
422+
// If we failed to canonicalize ownership, there was something in the SIL
423+
// that copy propagation did not understand. Emit a we did not understand
424+
// error.
425+
if (markedValue->getType().isMoveOnlyWrapped()) {
426+
diagnose(fn->getASTContext(), markedValue->getLoc().getSourceLoc(),
427+
diag::sil_moveonlychecker_not_understand_no_implicit_copy);
428+
} else {
429+
diagnose(fn->getASTContext(), markedValue->getLoc().getSourceLoc(),
430+
diag::sil_moveonlychecker_not_understand_moveonly);
431+
}
432+
valuesWithDiagnostics.insert(markedValue);
433+
continue;
434+
} else {
435+
// Always set changed to true if we succeeded in canonicalizing since we
436+
// may have rewritten copies.
437+
changed = true;
438+
}
422439

423440
// If we are asked to perform guaranteed checking, emit an error if we have
424441
// /any/ consuming uses.
@@ -532,6 +549,9 @@ class MoveOnlyCheckerPass : public SILFunctionTransform {
532549
assert(fn->getModule().getStage() == SILStage::Raw &&
533550
"Should only run on Raw SIL");
534551

552+
LLVM_DEBUG(llvm::dbgs() << "===> MoveOnly Object Checker. Visiting: "
553+
<< fn->getName() << '\n');
554+
535555
auto *accessBlockAnalysis = getAnalysis<NonLocalAccessBlockAnalysis>();
536556
auto *dominanceAnalysis = getAnalysis<DominanceAnalysis>();
537557
DominanceInfo *domTree = dominanceAnalysis->get(fn);

0 commit comments

Comments
 (0)