1+ use crate :: query:: Providers ;
2+
13use super :: * ;
24
35/// Preorder traversal of a graph.
4- ///
56/// Preorder traversal is when each node is visited after at least one of its predecessors. If you
67/// are familiar with some basic graph theory, then this performs a depth first search and returns
78/// nodes in order of discovery time.
@@ -280,8 +281,7 @@ pub fn reverse_postorder<'a, 'tcx>(
280281 body. basic_blocks . reverse_postorder ( ) . iter ( ) . map ( |& bb| ( bb, & body. basic_blocks [ bb] ) )
281282}
282283
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`].
285285///
286286/// This is allowed to have false positives; just because this says a block
287287/// is reachable doesn't mean that's necessarily true. It's thus always
@@ -292,12 +292,12 @@ pub fn reverse_postorder<'a, 'tcx>(
292292/// checks can be done without worrying about panicking.
293293///
294294/// 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 > (
298297 tcx : TyCtxt < ' tcx > ,
299298 instance : Instance < ' tcx > ,
300299) -> BitSet < BasicBlock > {
300+ let body = tcx. instance_mir ( instance. def ) ;
301301 let mut visitor = MonoReachable {
302302 body,
303303 tcx,
@@ -348,3 +348,7 @@ impl<'a, 'tcx> MonoReachable<'a, 'tcx> {
348348 }
349349 }
350350}
351+
352+ pub fn provide ( providers : & mut Providers ) {
353+ providers. reachable_blocks = reachable_blocks;
354+ }
0 commit comments