@@ -68,7 +68,7 @@ fn process<'tcx>(
68
68
involved : & mut FxHashSet < LocalDefId > ,
69
69
recursion_limiter : & mut FxHashMap < DefId , usize > ,
70
70
recursion_limit : Limit ,
71
- ) -> bool {
71
+ ) -> Option < bool > {
72
72
trace ! ( %caller) ;
73
73
let mut reaches_root = false ;
74
74
@@ -127,10 +127,9 @@ fn process<'tcx>(
127
127
recursion_limiter,
128
128
recursion_limit,
129
129
)
130
- } )
130
+ } ) ?
131
131
} else {
132
- // Pessimistically assume that there could be recursion.
133
- true
132
+ return None ;
134
133
} ;
135
134
seen. insert ( callee, callee_reaches_root) ;
136
135
callee_reaches_root
@@ -144,14 +143,14 @@ fn process<'tcx>(
144
143
}
145
144
}
146
145
147
- reaches_root
146
+ Some ( reaches_root)
148
147
}
149
148
150
149
#[ instrument( level = "debug" , skip( tcx) , ret) ]
151
150
pub ( crate ) fn mir_callgraph_cyclic < ' tcx > (
152
151
tcx : TyCtxt < ' tcx > ,
153
152
root : LocalDefId ,
154
- ) -> UnordSet < LocalDefId > {
153
+ ) -> Option < UnordSet < LocalDefId > > {
155
154
assert ! (
156
155
!tcx. is_constructor( root. to_def_id( ) ) ,
157
156
"you should not call `mir_callgraph_reachable` on enum/struct constructor functions"
@@ -164,16 +163,16 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
164
163
// limit, we will hit the limit first and give up on looking for inlining. And in any case,
165
164
// the default recursion limits are quite generous for us. If we need to recurse 64 times
166
165
// 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 ;
168
167
let mut involved = FxHashSet :: default ( ) ;
169
168
let typing_env = ty:: TypingEnv :: post_analysis ( tcx, root) ;
170
169
let root_instance =
171
170
ty:: Instance :: new_raw ( root. to_def_id ( ) , ty:: GenericArgs :: identity_for_item ( tcx, root) ) ;
172
171
if !should_recurse ( tcx, root_instance) {
173
172
trace ! ( "cannot walk, skipping" ) ;
174
- return involved. into ( ) ;
173
+ return Some ( involved. into ( ) ) ;
175
174
}
176
- process (
175
+ match process (
177
176
tcx,
178
177
typing_env,
179
178
root_instance,
@@ -182,8 +181,10 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
182
181
& mut involved,
183
182
& mut FxHashMap :: default ( ) ,
184
183
recursion_limit,
185
- ) ;
186
- involved. into ( )
184
+ ) {
185
+ Some ( _) => Some ( involved. into ( ) ) ,
186
+ _ => None ,
187
+ }
187
188
}
188
189
189
190
pub ( crate ) fn mir_inliner_callees < ' tcx > (
0 commit comments