@@ -1833,32 +1833,35 @@ visitRecursivelyLifetimeEndingUses(
1833
1833
llvm::function_ref<bool (Operand *)> visitScopeEnd,
1834
1834
llvm::function_ref<bool(Operand *)> visitUnknownUse) {
1835
1835
1836
- for (Operand *use : i->getConsumingUses ()) {
1837
- noUsers = false ;
1838
- if (isa<DestroyValueInst>(use->getUser ())) {
1839
- if (!visitScopeEnd (use)) {
1840
- return false ;
1836
+ StackList<SILValue> values (i->getFunction ());
1837
+ values.push_back (i);
1838
+
1839
+ while (!values.empty ()) {
1840
+ auto value = values.pop_back_val ();
1841
+ for (Operand *use : value->getConsumingUses ()) {
1842
+ noUsers = false ;
1843
+ if (isa<DestroyValueInst>(use->getUser ())) {
1844
+ if (!visitScopeEnd (use)) {
1845
+ return false ;
1846
+ }
1847
+ continue ;
1841
1848
}
1842
- continue ;
1843
- }
1844
- if ( auto *ret = dyn_cast<ReturnInst>(use-> getUser ())) {
1845
- auto fnTy = ret-> getFunction ()-> getLoweredFunctionType ();
1846
- assert (!fnTy-> getLifetimeDependencies (). empty ()) ;
1847
- if (! visitScopeEnd (use)) {
1848
- return false ;
1849
+ if ( auto *ret = dyn_cast<ReturnInst>(use-> getUser ())) {
1850
+ auto fnTy = ret-> getFunction ()-> getLoweredFunctionType ();
1851
+ assert (!fnTy-> getLifetimeDependencies (). empty ());
1852
+ if (! visitScopeEnd (use)) {
1853
+ return false ;
1854
+ }
1855
+ continue ;
1849
1856
}
1850
- continue ;
1851
- }
1852
- // FIXME: Handle store to indirect result
1857
+ // FIXME: Handle store to indirect result
1853
1858
1854
- auto *user = use->getUser ();
1855
- if (user->getNumResults () == 0 ) {
1856
- return visitUnknownUse (use);
1857
- }
1858
- for (auto res : use->getUser ()->getResults ()) {
1859
- if (!visitRecursivelyLifetimeEndingUses (res, noUsers, visitScopeEnd,
1860
- visitUnknownUse)) {
1861
- return false ;
1859
+ auto *user = use->getUser ();
1860
+ if (user->getNumResults () == 0 ) {
1861
+ return visitUnknownUse (use);
1862
+ }
1863
+ for (auto res : use->getUser ()->getResults ()) {
1864
+ values.push_back (res);
1862
1865
}
1863
1866
}
1864
1867
}
0 commit comments