|
10 | 10 | // * `Spanned<MonoItem>` is returned in `AccessMap` instead of just `MonoItem`. |
11 | 11 |
|
12 | 12 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
13 | | -use rustc_data_structures::sync::{par_for_each_in, MTLock, MTLockRef}; |
| 13 | +use rustc_data_structures::sync::{par_for_each_in, MTLock}; |
14 | 14 | use rustc_hir as hir; |
15 | 15 | use rustc_hir::def::DefKind; |
16 | 16 | use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId}; |
@@ -119,38 +119,33 @@ pub fn collect_crate_mono_items( |
119 | 119 |
|
120 | 120 | debug!("building mono item graph, beginning at roots"); |
121 | 121 |
|
122 | | - let mut visited = MTLock::new(FxHashSet::default()); |
123 | | - let mut usage_map = MTLock::new(UsageMap::new()); |
| 122 | + let visited = MTLock::new(FxHashSet::default()); |
| 123 | + let usage_map = MTLock::new(UsageMap::new()); |
124 | 124 | let recursion_limit = tcx.recursion_limit(); |
125 | 125 |
|
126 | | - { |
127 | | - let visited: MTLockRef<'_, _> = &mut visited; |
128 | | - let usage_map: MTLockRef<'_, _> = &mut usage_map; |
129 | | - |
130 | | - tcx.sess.time("monomorphization_collector_graph_walk", || { |
131 | | - par_for_each_in(roots, |root| { |
132 | | - let mut recursion_depths = DefIdMap::default(); |
133 | | - let should_gen = match root { |
134 | | - MonoItem::Static(def_id) => { |
135 | | - let instance = Instance::mono(tcx, def_id); |
136 | | - should_codegen_locally(tcx, &instance) |
137 | | - } |
138 | | - MonoItem::Fn(instance) => should_codegen_locally(tcx, &instance), |
139 | | - MonoItem::GlobalAsm(_) => true, |
140 | | - }; |
141 | | - if should_gen { |
142 | | - collect_items_rec( |
143 | | - tcx, |
144 | | - dummy_spanned(root), |
145 | | - visited, |
146 | | - &mut recursion_depths, |
147 | | - recursion_limit, |
148 | | - usage_map, |
149 | | - ); |
| 126 | + tcx.sess.time("monomorphization_collector_graph_walk", || { |
| 127 | + par_for_each_in(roots, |root| { |
| 128 | + let mut recursion_depths = DefIdMap::default(); |
| 129 | + let should_gen = match root { |
| 130 | + MonoItem::Static(def_id) => { |
| 131 | + let instance = Instance::mono(tcx, def_id); |
| 132 | + should_codegen_locally(tcx, &instance) |
150 | 133 | } |
151 | | - }); |
| 134 | + MonoItem::Fn(instance) => should_codegen_locally(tcx, &instance), |
| 135 | + MonoItem::GlobalAsm(_) => true, |
| 136 | + }; |
| 137 | + if should_gen { |
| 138 | + collect_items_rec( |
| 139 | + tcx, |
| 140 | + dummy_spanned(root), |
| 141 | + &visited, |
| 142 | + &mut recursion_depths, |
| 143 | + recursion_limit, |
| 144 | + &usage_map, |
| 145 | + ); |
| 146 | + } |
152 | 147 | }); |
153 | | - } |
| 148 | + }); |
154 | 149 |
|
155 | 150 | (visited.into_inner(), usage_map.into_inner()) |
156 | 151 | } |
@@ -204,10 +199,10 @@ fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionMode) -> Vec<MonoItem< |
204 | 199 | fn collect_items_rec<'tcx>( |
205 | 200 | tcx: TyCtxt<'tcx>, |
206 | 201 | starting_item: Spanned<MonoItem<'tcx>>, |
207 | | - visited: MTLockRef<'_, FxHashSet<MonoItem<'tcx>>>, |
| 202 | + visited: &MTLock<FxHashSet<MonoItem<'tcx>>>, |
208 | 203 | recursion_depths: &mut DefIdMap<usize>, |
209 | 204 | recursion_limit: Limit, |
210 | | - usage_map: MTLockRef<'_, UsageMap<'tcx>>, |
| 205 | + usage_map: &MTLock<UsageMap<'tcx>>, |
211 | 206 | ) { |
212 | 207 | if !visited.lock_mut().insert(starting_item.node) { |
213 | 208 | // We've been here already, no need to search again. |
|
0 commit comments