Skip to content

[value-move-function] Eliminate unnecessary book keeping. #41171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions lib/SILOptimizer/Mandatory/MoveKillsCopyableValuesChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ bool CheckerLivenessInfo::compute() {
while (SILValue value = defUseWorklist.pop()) {
LLVM_DEBUG(llvm::dbgs() << "New Value: " << value);
SWIFT_DEFER { LLVM_DEBUG(llvm::dbgs() << "Finished Value: " << value); };

for (Operand *use : value->getUses()) {
auto *user = use->getUser();
LLVM_DEBUG(llvm::dbgs() << " User: " << *user);
Expand Down Expand Up @@ -190,7 +191,6 @@ namespace {
struct MoveKillsCopyableValuesChecker {
SILFunction *fn;
CheckerLivenessInfo livenessInfo;
SmallSetVector<MoveValueInst *, 1> movesWithinLivenessBoundary;

MoveKillsCopyableValuesChecker(SILFunction *fn) : fn(fn) {}
bool check();
Expand Down Expand Up @@ -377,7 +377,6 @@ bool MoveKillsCopyableValuesChecker::check() {

// Then look at all of our found consuming uses. See if any of these are
// _move that are within the boundary.
SWIFT_DEFER { movesWithinLivenessBoundary.clear(); };
for (auto *use : livenessInfo.consumingUse) {
if (auto *mvi = dyn_cast<MoveValueInst>(use->getUser())) {
// Only emit diagnostics if our move value allows us to.
Expand All @@ -392,18 +391,12 @@ bool MoveKillsCopyableValuesChecker::check() {
LLVM_DEBUG(llvm::dbgs() << "Move Value: " << *mvi);
if (livenessInfo.liveness.isWithinBoundary(mvi)) {
LLVM_DEBUG(llvm::dbgs() << " WithinBoundary: Yes!\n");
movesWithinLivenessBoundary.insert(mvi);
emitDiagnosticForMove(lexicalValue, varName, mvi);
} else {
LLVM_DEBUG(llvm::dbgs() << " WithinBoundary: No!\n");
}
}
}

// Ok, we found all of our moves that violate the boundary condition, lets
// emit diagnostics for each of them.
for (auto *mvi : movesWithinLivenessBoundary) {
emitDiagnosticForMove(lexicalValue, varName, mvi);
}
}

return false;
Expand Down