Skip to content

Commit

Permalink
Bypass the query
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Apr 1, 2024
1 parent 5fa7d14 commit 5a6e55a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub fn reverse_postorder<'a, 'tcx>(
/// of `if <T as Trait>::CONST`, as well as [`NullOp::UbChecks`].
///
/// [`NullOp::UbChecks`]: rustc_middle::mir::NullOp::UbChecks
fn reachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> BitSet<BasicBlock> {
pub fn reachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> BitSet<BasicBlock> {
let body = tcx.instance_mir(instance.def);
let mut visitor = MonoReachable {
body,
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ struct MirUsedCollector<'a, 'tcx> {
visiting_call_terminator: bool,
/// Set of functions for which it is OK to move large data into.
skip_move_check_fns: Option<Vec<DefId>>,
reachable_blocks: Option<&'tcx BitSet<mir::BasicBlock>>,
reachable_blocks: Option<BitSet<mir::BasicBlock>>,
}

impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> {
Expand Down Expand Up @@ -836,6 +836,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
fn visit_basic_block_data(&mut self, block: mir::BasicBlock, data: &mir::BasicBlockData<'tcx>) {
if self
.reachable_blocks
.as_ref()
.expect("we should only walk blocks with CollectionMode::UsedItems")
.contains(block)
{
Expand Down Expand Up @@ -1414,6 +1415,7 @@ fn collect_items_of_instance<'tcx>(
// added to `used_items` in a hash set, which can efficiently query in the
// `body.mentioned_items` loop below without even having to monomorphize the item.
let mut used_mentioned_items = FxHashSet::<MentionedItem<'tcx>>::default();

let mut collector = MirUsedCollector {
tcx,
body,
Expand All @@ -1424,7 +1426,7 @@ fn collect_items_of_instance<'tcx>(
visiting_call_terminator: false,
skip_move_check_fns: None,
reachable_blocks: if mode == CollectionMode::UsedItems {
Some(tcx.reachable_blocks(instance))
Some(rustc_middle::mir::traversal::reachable_blocks(tcx, instance))
} else {
None
},
Expand Down

0 comments on commit 5a6e55a

Please sign in to comment.