Skip to content

Commit f487764

Browse files
committed
[move-only][borrow2destructure] Add support for processing switch_enum.
As mentioned previously, I am right now creating new Implementations for each switch_enum argument. Once I get tests working I am going to refactor and reuse the same implementation so I can reuse memory. NOTE: This currently does not impact SILGen since I did not change SILGenPattern to emit noncopyable switched upon values as guaranteed. Keep in mind that I am not going to do this for no implicit copy though since no implicit copy values cannot contain move only values so we do not need to work with destructures.
1 parent e9e704e commit f487764

File tree

4 files changed

+715
-34
lines changed

4 files changed

+715
-34
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressChecker.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,44 @@ class MoveOnlyCheckerPass : public SILFunctionTransform {
19861986
if (MoveOnlyChecker(getFunction(), deAnalysis, domTree).checkFunction()) {
19871987
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
19881988
}
1989+
1990+
if (!getOptions().VerifyAll)
1991+
return;
1992+
1993+
// TODO: Enable this by default when verify all is disabled and make it a
1994+
// diagnostic error saying file a bug.
1995+
for (auto &block : *getFunction()) {
1996+
for (auto &inst : block) {
1997+
if (auto *cvi = dyn_cast<CopyValueInst>(&inst)) {
1998+
if (cvi->getOperand()->getType().isMoveOnly()) {
1999+
llvm::errs() << "Should have eliminated copy at this point: "
2000+
<< *cvi;
2001+
llvm::report_fatal_error("standard compiler error");
2002+
}
2003+
continue;
2004+
}
2005+
2006+
if (auto *li = dyn_cast<LoadInst>(&inst)) {
2007+
if (li->getOwnershipQualifier() == LoadOwnershipQualifier::Copy &&
2008+
li->getType().isMoveOnly()) {
2009+
llvm::errs() << "Should have eliminated copy at this point: "
2010+
<< *li;
2011+
llvm::report_fatal_error("standard compiler error");
2012+
}
2013+
continue;
2014+
}
2015+
2016+
if (auto *copyAddr = dyn_cast<CopyAddrInst>(&inst)) {
2017+
if (!copyAddr->isTakeOfSrc() &&
2018+
copyAddr->getSrc()->getType().isMoveOnly()) {
2019+
llvm::errs() << "Should have eliminated copy at this point: "
2020+
<< *copyAddr;
2021+
llvm::report_fatal_error("standard compiler error");
2022+
}
2023+
continue;
2024+
}
2025+
}
2026+
}
19892027
}
19902028
};
19912029

0 commit comments

Comments
 (0)