Skip to content

Commit ae006b6

Browse files
committed
[Gardening] Sunk static function to use.
Now that the other caller of the function has been removed, it's more convenient to have it adjacent to the only remaining caller.
1 parent aaad438 commit ae006b6

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,49 +1825,8 @@ bool SILInstruction::maySuspend() const {
18251825
if (auto applySite = FullApplySite::isa(const_cast<SILInstruction*>(this))) {
18261826
return applySite.getOrigCalleeType()->isAsync();
18271827
}
1828-
1829-
return false;
1830-
}
1831-
1832-
static bool
1833-
visitRecursivelyLifetimeEndingUses(
1834-
SILValue i, bool &noUsers,
1835-
llvm::function_ref<bool(Operand *)> visitScopeEnd,
1836-
llvm::function_ref<bool(Operand *)> visitUnknownUse) {
1837-
1838-
StackList<SILValue> values(i->getFunction());
1839-
values.push_back(i);
1840-
1841-
while (!values.empty()) {
1842-
auto value = values.pop_back_val();
1843-
for (Operand *use : value->getConsumingUses()) {
1844-
noUsers = false;
1845-
if (isa<DestroyValueInst>(use->getUser())) {
1846-
if (!visitScopeEnd(use)) {
1847-
return false;
1848-
}
1849-
continue;
1850-
}
1851-
if (auto *ret = dyn_cast<ReturnInst>(use->getUser())) {
1852-
auto fnTy = ret->getFunction()->getLoweredFunctionType();
1853-
assert(!fnTy->getLifetimeDependencies().empty());
1854-
if (!visitScopeEnd(use)) {
1855-
return false;
1856-
}
1857-
continue;
1858-
}
1859-
// FIXME: Handle store to indirect result
18601828

1861-
auto *user = use->getUser();
1862-
if (user->getNumResults() == 0) {
1863-
return visitUnknownUse(use);
1864-
}
1865-
for (auto res : use->getUser()->getResults()) {
1866-
values.push_back(res);
1867-
}
1868-
}
1869-
}
1870-
return true;
1829+
return false;
18711830
}
18721831

18731832
bool
@@ -1964,6 +1923,47 @@ FunctionTest PartialApplyPrintOnStackLifetimeEnds(
19641923
});
19651924
} // end namespace swift::test
19661925

1926+
static bool
1927+
visitRecursivelyLifetimeEndingUses(
1928+
SILValue i, bool &noUsers,
1929+
llvm::function_ref<bool(Operand *)> visitScopeEnd,
1930+
llvm::function_ref<bool(Operand *)> visitUnknownUse) {
1931+
1932+
StackList<SILValue> values(i->getFunction());
1933+
values.push_back(i);
1934+
1935+
while (!values.empty()) {
1936+
auto value = values.pop_back_val();
1937+
for (Operand *use : value->getConsumingUses()) {
1938+
noUsers = false;
1939+
if (isa<DestroyValueInst>(use->getUser())) {
1940+
if (!visitScopeEnd(use)) {
1941+
return false;
1942+
}
1943+
continue;
1944+
}
1945+
if (auto *ret = dyn_cast<ReturnInst>(use->getUser())) {
1946+
auto fnTy = ret->getFunction()->getLoweredFunctionType();
1947+
assert(!fnTy->getLifetimeDependencies().empty());
1948+
if (!visitScopeEnd(use)) {
1949+
return false;
1950+
}
1951+
continue;
1952+
}
1953+
// FIXME: Handle store to indirect result
1954+
1955+
auto *user = use->getUser();
1956+
if (user->getNumResults() == 0) {
1957+
return visitUnknownUse(use);
1958+
}
1959+
for (auto res : use->getUser()->getResults()) {
1960+
values.push_back(res);
1961+
}
1962+
}
1963+
}
1964+
return true;
1965+
}
1966+
19671967
// FIXME: Rather than recursing through all results, this should only recurse
19681968
// through ForwardingInstruction and OwnershipTransitionInstruction and the
19691969
// client should prove that any other uses cannot be upstream from a consume of

0 commit comments

Comments
 (0)