1
+ use crate :: query:: Providers ;
2
+
1
3
use super :: * ;
2
4
3
5
/// Preorder traversal of a graph.
4
- ///
5
6
/// Preorder traversal is when each node is visited after at least one of its predecessors. If you
6
7
/// are familiar with some basic graph theory, then this performs a depth first search and returns
7
8
/// nodes in order of discovery time.
@@ -280,8 +281,7 @@ pub fn reverse_postorder<'a, 'tcx>(
280
281
body. basic_blocks . reverse_postorder ( ) . iter ( ) . map ( |& bb| ( bb, & body. basic_blocks [ bb] ) )
281
282
}
282
283
283
- /// Finds which basic blocks are actually reachable for a specific
284
- /// monomorphization of this body.
284
+ /// Finds which basic blocks are actually reachable for a monomorphized [`Instance`].
285
285
///
286
286
/// This is allowed to have false positives; just because this says a block
287
287
/// is reachable doesn't mean that's necessarily true. It's thus always
@@ -292,12 +292,12 @@ pub fn reverse_postorder<'a, 'tcx>(
292
292
/// checks can be done without worrying about panicking.
293
293
///
294
294
/// This is mostly useful because it lets us skip lowering the `false` side
295
- /// of `if <T as Trait>::CONST`, as well as `intrinsics::debug_assertions`.
296
- pub fn reachable_blocks_in_mono < ' tcx > (
297
- body : & Body < ' tcx > ,
295
+ /// of `if <T as Trait>::CONST`, as well as [`intrinsics::ub_checks`].
296
+ fn reachable_blocks < ' tcx > (
298
297
tcx : TyCtxt < ' tcx > ,
299
298
instance : Instance < ' tcx > ,
300
299
) -> BitSet < BasicBlock > {
300
+ let body = tcx. instance_mir ( instance. def ) ;
301
301
let mut visitor = MonoReachable {
302
302
body,
303
303
tcx,
@@ -348,3 +348,7 @@ impl<'a, 'tcx> MonoReachable<'a, 'tcx> {
348
348
}
349
349
}
350
350
}
351
+
352
+ pub fn provide ( providers : & mut Providers ) {
353
+ providers. reachable_blocks = reachable_blocks;
354
+ }
0 commit comments