Skip to content

Commit 41bee47

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 ad9e090 commit 41bee47

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,47 +1831,6 @@ bool SILInstruction::maySuspend() const {
18311831
return false;
18321832
}
18331833

1834-
static bool
1835-
visitRecursivelyLifetimeEndingUses(
1836-
SILValue i, bool &noUsers,
1837-
llvm::function_ref<bool(Operand *)> visitScopeEnd,
1838-
llvm::function_ref<bool(Operand *)> visitUnknownUse) {
1839-
1840-
StackList<SILValue> values(i->getFunction());
1841-
values.push_back(i);
1842-
1843-
while (!values.empty()) {
1844-
auto value = values.pop_back_val();
1845-
for (Operand *use : value->getConsumingUses()) {
1846-
noUsers = false;
1847-
if (isa<DestroyValueInst>(use->getUser())) {
1848-
if (!visitScopeEnd(use)) {
1849-
return false;
1850-
}
1851-
continue;
1852-
}
1853-
if (auto *ret = dyn_cast<ReturnInst>(use->getUser())) {
1854-
auto fnTy = ret->getFunction()->getLoweredFunctionType();
1855-
assert(!fnTy->getLifetimeDependencies().empty());
1856-
if (!visitScopeEnd(use)) {
1857-
return false;
1858-
}
1859-
continue;
1860-
}
1861-
// FIXME: Handle store to indirect result
1862-
1863-
auto *user = use->getUser();
1864-
if (user->getNumResults() == 0) {
1865-
return visitUnknownUse(use);
1866-
}
1867-
for (auto res : use->getUser()->getResults()) {
1868-
values.push_back(res);
1869-
}
1870-
}
1871-
}
1872-
return true;
1873-
}
1874-
18751834
static SILValue lookThroughOwnershipAndForwardingInsts(SILValue value) {
18761835
auto current = value;
18771836
while (true) {
@@ -2000,6 +1959,47 @@ FunctionTest PartialApplyPrintOnStackLifetimeEnds(
20001959
});
20011960
} // end namespace swift::test
20021961

1962+
static bool
1963+
visitRecursivelyLifetimeEndingUses(
1964+
SILValue i, bool &noUsers,
1965+
llvm::function_ref<bool(Operand *)> visitScopeEnd,
1966+
llvm::function_ref<bool(Operand *)> visitUnknownUse) {
1967+
1968+
StackList<SILValue> values(i->getFunction());
1969+
values.push_back(i);
1970+
1971+
while (!values.empty()) {
1972+
auto value = values.pop_back_val();
1973+
for (Operand *use : value->getConsumingUses()) {
1974+
noUsers = false;
1975+
if (isa<DestroyValueInst>(use->getUser())) {
1976+
if (!visitScopeEnd(use)) {
1977+
return false;
1978+
}
1979+
continue;
1980+
}
1981+
if (auto *ret = dyn_cast<ReturnInst>(use->getUser())) {
1982+
auto fnTy = ret->getFunction()->getLoweredFunctionType();
1983+
assert(!fnTy->getLifetimeDependencies().empty());
1984+
if (!visitScopeEnd(use)) {
1985+
return false;
1986+
}
1987+
continue;
1988+
}
1989+
// FIXME: Handle store to indirect result
1990+
1991+
auto *user = use->getUser();
1992+
if (user->getNumResults() == 0) {
1993+
return visitUnknownUse(use);
1994+
}
1995+
for (auto res : use->getUser()->getResults()) {
1996+
values.push_back(res);
1997+
}
1998+
}
1999+
}
2000+
return true;
2001+
}
2002+
20032003
// FIXME: Rather than recursing through all results, this should only recurse
20042004
// through ForwardingInstruction and OwnershipTransitionInstruction and the
20052005
// client should prove that any other uses cannot be upstream from a consume of

0 commit comments

Comments
 (0)