@@ -68,7 +68,7 @@ fn process<'tcx>(
6868 involved : & mut FxHashSet < LocalDefId > ,
6969 recursion_limiter : & mut FxHashMap < DefId , usize > ,
7070 recursion_limit : Limit ,
71- ) -> bool {
71+ ) -> Option < bool > {
7272 trace ! ( %caller) ;
7373 let mut reaches_root = false ;
7474
@@ -127,10 +127,9 @@ fn process<'tcx>(
127127 recursion_limiter,
128128 recursion_limit,
129129 )
130- } )
130+ } ) ?
131131 } else {
132- // Pessimistically assume that there could be recursion.
133- true
132+ return None ;
134133 } ;
135134 seen. insert ( callee, callee_reaches_root) ;
136135 callee_reaches_root
@@ -144,14 +143,14 @@ fn process<'tcx>(
144143 }
145144 }
146145
147- reaches_root
146+ Some ( reaches_root)
148147}
149148
150149#[ instrument( level = "debug" , skip( tcx) , ret) ]
151150pub ( crate ) fn mir_callgraph_cyclic < ' tcx > (
152151 tcx : TyCtxt < ' tcx > ,
153152 root : LocalDefId ,
154- ) -> UnordSet < LocalDefId > {
153+ ) -> Option < UnordSet < LocalDefId > > {
155154 assert ! (
156155 !tcx. is_constructor( root. to_def_id( ) ) ,
157156 "you should not call `mir_callgraph_reachable` on enum/struct constructor functions"
@@ -164,16 +163,16 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
164163 // limit, we will hit the limit first and give up on looking for inlining. And in any case,
165164 // the default recursion limits are quite generous for us. If we need to recurse 64 times
166165 // into the call graph, we're probably not going to find any useful MIR inlining.
167- let recursion_limit = tcx. recursion_limit ( ) / 2 ;
166+ let recursion_limit = tcx. recursion_limit ( ) / 8 ;
168167 let mut involved = FxHashSet :: default ( ) ;
169168 let typing_env = ty:: TypingEnv :: post_analysis ( tcx, root) ;
170169 let root_instance =
171170 ty:: Instance :: new_raw ( root. to_def_id ( ) , ty:: GenericArgs :: identity_for_item ( tcx, root) ) ;
172171 if !should_recurse ( tcx, root_instance) {
173172 trace ! ( "cannot walk, skipping" ) ;
174- return involved. into ( ) ;
173+ return Some ( involved. into ( ) ) ;
175174 }
176- process (
175+ match process (
177176 tcx,
178177 typing_env,
179178 root_instance,
@@ -182,8 +181,10 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
182181 & mut involved,
183182 & mut FxHashMap :: default ( ) ,
184183 recursion_limit,
185- ) ;
186- involved. into ( )
184+ ) {
185+ Some ( _) => Some ( involved. into ( ) ) ,
186+ _ => None ,
187+ }
187188}
188189
189190pub ( crate ) fn mir_inliner_callees < ' tcx > (
0 commit comments