Skip to content

Commit 769439f

Browse files
committed
[ownership] Extract SILValueOwnershipChecker::check() into an out of line function.
1 parent f664be4 commit 769439f

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,7 @@ class SILValueOwnershipChecker {
123123
SILValueOwnershipChecker(SILValueOwnershipChecker &) = delete;
124124
SILValueOwnershipChecker(SILValueOwnershipChecker &&) = delete;
125125

126-
bool check() {
127-
if (result.hasValue())
128-
return result.getValue();
129-
130-
LLVM_DEBUG(llvm::dbgs() << "Verifying ownership of: " << *value);
131-
result = checkUses();
132-
if (!result.getValue())
133-
return false;
134-
135-
SmallVector<BranchPropagatedUser, 32> allLifetimeEndingUsers;
136-
llvm::copy(lifetimeEndingUsers, std::back_inserter(allLifetimeEndingUsers));
137-
SmallVector<BranchPropagatedUser, 32> allRegularUsers;
138-
llvm::copy(regularUsers, std::back_inserter(allRegularUsers));
139-
llvm::copy(implicitRegularUsers, std::back_inserter(allRegularUsers));
140-
141-
LinearLifetimeChecker checker(visitedBlocks, deadEndBlocks);
142-
auto linearLifetimeResult = checker.checkValue(
143-
value, allLifetimeEndingUsers, allRegularUsers, errorBehavior);
144-
result = !linearLifetimeResult.getFoundError();
145-
146-
return result.getValue();
147-
}
126+
bool check();
148127

149128
private:
150129
bool checkUses();
@@ -182,6 +161,29 @@ class SILValueOwnershipChecker {
182161

183162
} // end anonymous namespace
184163

164+
bool SILValueOwnershipChecker::check() {
165+
if (result.hasValue())
166+
return result.getValue();
167+
168+
LLVM_DEBUG(llvm::dbgs() << "Verifying ownership of: " << *value);
169+
result = checkUses();
170+
if (!result.getValue())
171+
return false;
172+
173+
SmallVector<BranchPropagatedUser, 32> allLifetimeEndingUsers;
174+
llvm::copy(lifetimeEndingUsers, std::back_inserter(allLifetimeEndingUsers));
175+
SmallVector<BranchPropagatedUser, 32> allRegularUsers;
176+
llvm::copy(regularUsers, std::back_inserter(allRegularUsers));
177+
llvm::copy(implicitRegularUsers, std::back_inserter(allRegularUsers));
178+
179+
LinearLifetimeChecker checker(visitedBlocks, deadEndBlocks);
180+
auto linearLifetimeResult = checker.checkValue(
181+
value, allLifetimeEndingUsers, allRegularUsers, errorBehavior);
182+
result = !linearLifetimeResult.getFoundError();
183+
184+
return result.getValue();
185+
}
186+
185187
bool SILValueOwnershipChecker::gatherUsers(
186188
SmallVectorImpl<Operand *> &lifetimeEndingUsers,
187189
SmallVectorImpl<Operand *> &nonLifetimeEndingUsers,

0 commit comments

Comments
 (0)