Skip to content

Commit 6bdc8be

Browse files
committed
Auto merge of #49991 - wesleywiser:remove_hir_inlining, r=<try>
Remove HIR inlining Fixes #49690 r? @michaelwoerister
2 parents 49317cd + 26b3203 commit 6bdc8be

File tree

14 files changed

+63
-211
lines changed

14 files changed

+63
-211
lines changed

src/librustc/dep_graph/dep_node.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ define_dep_nodes!( <'tcx>
556556
[input] DefSpan(DefId),
557557
[] LookupStability(DefId),
558558
[] LookupDeprecationEntry(DefId),
559-
[] ItemBodyNestedBodies(DefId),
560559
[] ConstIsRvaluePromotableToStatic(DefId),
561560
[] RvaluePromotableMap(DefId),
562561
[] ImplParent(DefId),
@@ -567,6 +566,7 @@ define_dep_nodes!( <'tcx>
567566
[] ItemAttrs(DefId),
568567
[] TransFnAttrs(DefId),
569568
[] FnArgNames(DefId),
569+
[] RenderedConst(DefId),
570570
[] DylibDepFormats(CrateNum),
571571
[] IsPanicRuntime(CrateNum),
572572
[] IsCompilerBuiltins(CrateNum),
@@ -615,7 +615,6 @@ define_dep_nodes!( <'tcx>
615615
[input] GetLangItems,
616616
[] DefinedLangItems(CrateNum),
617617
[] MissingLangItems(CrateNum),
618-
[] ExternConstBody(DefId),
619618
[] VisibleParentMap,
620619
[input] MissingExternCrateItem(CrateNum),
621620
[input] UsedCrateSource(CrateNum),

src/librustc/hir/map/mod.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ use syntax_pos::Span;
3030
use hir::*;
3131
use hir::print::Nested;
3232
use hir::svh::Svh;
33-
use util::nodemap::{DefIdMap, FxHashMap};
33+
use util::nodemap::FxHashMap;
3434

35-
use arena::TypedArena;
3635
use std::io;
3736
use ty::TyCtxt;
3837

39-
use rustc_data_structures::sync::Lock;
40-
4138
pub mod blocks;
4239
mod collector;
4340
mod def_collector;
@@ -219,15 +216,13 @@ impl<'hir> MapEntry<'hir> {
219216
pub struct Forest {
220217
krate: Crate,
221218
pub dep_graph: DepGraph,
222-
inlined_bodies: TypedArena<Body>
223219
}
224220

225221
impl Forest {
226222
pub fn new(krate: Crate, dep_graph: &DepGraph) -> Forest {
227223
Forest {
228224
krate,
229225
dep_graph: dep_graph.clone(),
230-
inlined_bodies: TypedArena::new()
231226
}
232227
}
233228

@@ -264,9 +259,6 @@ pub struct Map<'hir> {
264259

265260
definitions: &'hir Definitions,
266261

267-
/// Bodies inlined from other crates are cached here.
268-
inlined_bodies: Lock<DefIdMap<&'hir Body>>,
269-
270262
/// The reverse mapping of `node_to_hir_id`.
271263
hir_to_node_id: FxHashMap<HirId, NodeId>,
272264
}
@@ -923,21 +915,6 @@ impl<'hir> Map<'hir> {
923915
}
924916
}
925917

926-
pub fn get_inlined_body_untracked(&self, def_id: DefId) -> Option<&'hir Body> {
927-
self.inlined_bodies.borrow().get(&def_id).cloned()
928-
}
929-
930-
pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'hir Body {
931-
let mut inlined_bodies = self.inlined_bodies.borrow_mut();
932-
if let Some(&b) = inlined_bodies.get(&def_id) {
933-
debug_assert_eq!(&body, b);
934-
return b;
935-
}
936-
let body = self.forest.inlined_bodies.alloc(body);
937-
inlined_bodies.insert(def_id, body);
938-
body
939-
}
940-
941918
/// Returns the name associated with the given NodeId's AST.
942919
pub fn name(&self, id: NodeId) -> Name {
943920
match self.get(id) {
@@ -1195,7 +1172,6 @@ pub fn map_crate<'hir>(sess: &::session::Session,
11951172
map,
11961173
hir_to_node_id,
11971174
definitions,
1198-
inlined_bodies: Lock::new(DefIdMap()),
11991175
};
12001176

12011177
hir_id_validator::check_crate(&map);

src/librustc/ich/impls_cstore.rs

-13
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,3 @@ impl<HCX> HashStable<HCX> for middle::cstore::ExternBodyNestedBodies {
7777
fingerprint.hash_stable(hcx, hasher);
7878
}
7979
}
80-
81-
impl<'a, HCX> HashStable<HCX> for middle::cstore::ExternConstBody<'a> {
82-
fn hash_stable<W: StableHasherResult>(&self,
83-
hcx: &mut HCX,
84-
hasher: &mut StableHasher<W>) {
85-
let middle::cstore::ExternConstBody {
86-
body: _,
87-
fingerprint,
88-
} = *self;
89-
90-
fingerprint.hash_stable(hcx, hasher);
91-
}
92-
}

src/librustc/middle/cstore.rs

-10
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,6 @@ pub trait MetadataLoader {
209209
-> Result<MetadataRef, String>;
210210
}
211211

212-
#[derive(Clone)]
213-
pub struct ExternConstBody<'tcx> {
214-
pub body: &'tcx hir::Body,
215-
216-
// It would require a lot of infrastructure to enable stable-hashing Bodies
217-
// from other crates, so we hash on export and just store the fingerprint
218-
// with them.
219-
pub fingerprint: ich::Fingerprint,
220-
}
221-
222212
#[derive(Clone)]
223213
pub struct ExternBodyNestedBodies {
224214
pub nested_bodies: Lrc<BTreeMap<hir::BodyId, hir::Body>>,

src/librustc/ty/maps/config.rs

-6
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> {
283283
}
284284
}
285285

286-
impl<'tcx> QueryDescription<'tcx> for queries::item_body_nested_bodies<'tcx> {
287-
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
288-
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
289-
}
290-
}
291-
292286
impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> {
293287
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
294288
format!("const checking if rvalue is promotable to static `{}`",

src/librustc/ty/maps/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ use hir::svh::Svh;
1717
use infer::canonical::{self, Canonical};
1818
use lint;
1919
use middle::borrowck::BorrowCheckResult;
20-
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary,
21-
ExternBodyNestedBodies, ForeignModule};
22-
use middle::cstore::{NativeLibraryKind, DepKind, CrateSource, ExternConstBody};
20+
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
21+
use middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
2322
use middle::privacy::AccessLevels;
2423
use middle::reachable::ReachableSet;
2524
use middle::region;
@@ -254,9 +253,9 @@ define_maps! { <'tcx>
254253
[] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
255254
[] fn trans_fn_attrs: trans_fn_attrs(DefId) -> TransFnAttrs,
256255
[] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
256+
[] fn rendered_const: RenderedConst(DefId) -> String,
257257
[] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
258258
[] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
259-
[] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> ExternBodyNestedBodies,
260259
[] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
261260
[] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
262261
[] fn is_mir_available: IsMirAvailable(DefId) -> bool,
@@ -376,7 +375,6 @@ define_maps! { <'tcx>
376375
[] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
377376
[] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
378377
[] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
379-
[] fn extern_const_body: ExternConstBody(DefId) -> ExternConstBody<'tcx>,
380378
[] fn visible_parent_map: visible_parent_map_node(CrateNum)
381379
-> Lrc<DefIdMap<DefId>>,
382380
[] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,

src/librustc/ty/maps/plumbing.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
10401040
DepKind::LookupDeprecationEntry => {
10411041
force!(lookup_deprecation_entry, def_id!());
10421042
}
1043-
DepKind::ItemBodyNestedBodies => { force!(item_body_nested_bodies, def_id!()); }
10441043
DepKind::ConstIsRvaluePromotableToStatic => {
10451044
force!(const_is_rvalue_promotable_to_static, def_id!());
10461045
}
@@ -1055,6 +1054,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
10551054
DepKind::ItemAttrs => { force!(item_attrs, def_id!()); }
10561055
DepKind::TransFnAttrs => { force!(trans_fn_attrs, def_id!()); }
10571056
DepKind::FnArgNames => { force!(fn_arg_names, def_id!()); }
1057+
DepKind::RenderedConst => { force!(rendered_const, def_id!()); }
10581058
DepKind::DylibDepFormats => { force!(dylib_dependency_formats, krate!()); }
10591059
DepKind::IsPanicRuntime => { force!(is_panic_runtime, krate!()); }
10601060
DepKind::IsCompilerBuiltins => { force!(is_compiler_builtins, krate!()); }
@@ -1111,7 +1111,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
11111111
DepKind::GetLangItems => { force!(get_lang_items, LOCAL_CRATE); }
11121112
DepKind::DefinedLangItems => { force!(defined_lang_items, krate!()); }
11131113
DepKind::MissingLangItems => { force!(missing_lang_items, krate!()); }
1114-
DepKind::ExternConstBody => { force!(extern_const_body, def_id!()); }
11151114
DepKind::VisibleParentMap => { force!(visible_parent_map, LOCAL_CRATE); }
11161115
DepKind::MissingExternCrateItem => {
11171116
force!(missing_extern_crate_item, krate!());

src/librustc_metadata/astencode.rs

+2-56
Original file line numberDiff line numberDiff line change
@@ -8,89 +8,35 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::hir::intravisit::{Visitor, NestedVisitorMap};
12-
1311
use isolated_encoder::IsolatedEncoder;
1412
use schema::*;
1513

1614
use rustc::hir;
17-
use rustc::ty::{self, TyCtxt};
18-
19-
use rustc::ich::Fingerprint;
20-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
15+
use rustc::ty;
2116

2217
#[derive(RustcEncodable, RustcDecodable)]
2318
pub struct Ast<'tcx> {
24-
pub body: Lazy<hir::Body>,
2519
pub tables: Lazy<ty::TypeckTables<'tcx>>,
26-
pub nested_bodies: LazySeq<hir::Body>,
2720
pub rvalue_promotable_to_static: bool,
28-
pub stable_bodies_hash: Fingerprint,
2921
}
3022

3123
impl_stable_hash_for!(struct Ast<'tcx> {
32-
body,
3324
tables,
34-
nested_bodies,
35-
rvalue_promotable_to_static,
36-
stable_bodies_hash
25+
rvalue_promotable_to_static
3726
});
3827

3928
impl<'a, 'b, 'tcx> IsolatedEncoder<'a, 'b, 'tcx> {
4029
pub fn encode_body(&mut self, body_id: hir::BodyId) -> Lazy<Ast<'tcx>> {
41-
let body = self.tcx.hir.body(body_id);
42-
43-
// In order to avoid having to hash hir::Bodies from extern crates, we
44-
// hash them here, during export, and store the hash with metadata.
45-
let stable_bodies_hash = {
46-
let mut hcx = self.tcx.create_stable_hashing_context();
47-
let mut hasher = StableHasher::new();
48-
49-
hcx.while_hashing_hir_bodies(true, |hcx| {
50-
body.hash_stable(hcx, &mut hasher);
51-
});
52-
53-
hasher.finish()
54-
};
55-
56-
let lazy_body = self.lazy(body);
5730
let body_owner_def_id = self.tcx.hir.body_owner_def_id(body_id);
5831
let tables = self.tcx.typeck_tables_of(body_owner_def_id);
5932
let lazy_tables = self.lazy(tables);
6033

61-
let mut visitor = NestedBodyCollector {
62-
tcx: self.tcx,
63-
bodies_found: Vec::new(),
64-
};
65-
visitor.visit_body(body);
66-
let lazy_nested_bodies = self.lazy_seq_ref_from_slice(&visitor.bodies_found);
67-
6834
let rvalue_promotable_to_static =
6935
self.tcx.const_is_rvalue_promotable_to_static(body_owner_def_id);
7036

7137
self.lazy(&Ast {
72-
body: lazy_body,
7338
tables: lazy_tables,
74-
nested_bodies: lazy_nested_bodies,
7539
rvalue_promotable_to_static,
76-
stable_bodies_hash,
7740
})
7841
}
7942
}
80-
81-
struct NestedBodyCollector<'a, 'tcx: 'a> {
82-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
83-
bodies_found: Vec<&'tcx hir::Body>,
84-
}
85-
86-
impl<'a, 'tcx: 'a> Visitor<'tcx> for NestedBodyCollector<'a, 'tcx> {
87-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
88-
NestedVisitorMap::None
89-
}
90-
91-
fn visit_nested_body(&mut self, body: hir::BodyId) {
92-
let body = self.tcx.hir.body(body);
93-
self.bodies_found.push(body);
94-
self.visit_body(body);
95-
}
96-
}

src/librustc_metadata/cstore_impl.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
161161
// This is only used by rustdoc anyway, which shouldn't have
162162
// incremental recompilation ever enabled.
163163
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
164+
rendered_const => { cdata.get_rendered_const(def_id.index) }
164165
impl_parent => { cdata.get_parent_impl(def_id.index) }
165166
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
166-
item_body_nested_bodies => { cdata.item_body_nested_bodies(tcx, def_id.index) }
167167
const_is_rvalue_promotable_to_static => {
168168
cdata.const_is_rvalue_promotable_to_static(def_id.index)
169169
}
@@ -243,11 +243,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
243243
defined_lang_items => { Lrc::new(cdata.get_lang_items()) }
244244
missing_lang_items => { Lrc::new(cdata.get_missing_lang_items()) }
245245

246-
extern_const_body => {
247-
debug!("item_body({:?}): inlining item", def_id);
248-
cdata.extern_const_body(tcx, def_id.index)
249-
}
250-
251246
missing_extern_crate_item => {
252247
let r = match *cdata.extern_crate.borrow() {
253248
Some(extern_crate) if !extern_crate.direct => true,

0 commit comments

Comments
 (0)