Skip to content

Commit

Permalink
Auto merge of #49991 - wesleywiser:remove_hir_inlining, r=michaelwoer…
Browse files Browse the repository at this point in the history
…ister

Remove HIR inlining

Fixes #49690

r? @michaelwoerister
  • Loading branch information
bors committed Apr 20, 2018
2 parents 257d43d + 4a77d35 commit 1a44439
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 331 deletions.
3 changes: 1 addition & 2 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ define_dep_nodes!( <'tcx>
[input] DefSpan(DefId),
[] LookupStability(DefId),
[] LookupDeprecationEntry(DefId),
[] ItemBodyNestedBodies(DefId),
[] ConstIsRvaluePromotableToStatic(DefId),
[] RvaluePromotableMap(DefId),
[] ImplParent(DefId),
Expand All @@ -567,6 +566,7 @@ define_dep_nodes!( <'tcx>
[] ItemAttrs(DefId),
[] TransFnAttrs(DefId),
[] FnArgNames(DefId),
[] RenderedConst(DefId),
[] DylibDepFormats(CrateNum),
[] IsPanicRuntime(CrateNum),
[] IsCompilerBuiltins(CrateNum),
Expand Down Expand Up @@ -615,7 +615,6 @@ define_dep_nodes!( <'tcx>
[input] GetLangItems,
[] DefinedLangItems(CrateNum),
[] MissingLangItems(CrateNum),
[] ExternConstBody(DefId),
[] VisibleParentMap,
[input] MissingExternCrateItem(CrateNum),
[input] UsedCrateSource(CrateNum),
Expand Down
26 changes: 1 addition & 25 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ use syntax_pos::Span;
use hir::*;
use hir::print::Nested;
use hir::svh::Svh;
use util::nodemap::{DefIdMap, FxHashMap};
use util::nodemap::FxHashMap;

use arena::SyncTypedArena;
use std::io;
use ty::TyCtxt;

use rustc_data_structures::sync::Lock;

pub mod blocks;
mod collector;
mod def_collector;
Expand Down Expand Up @@ -219,15 +216,13 @@ impl<'hir> MapEntry<'hir> {
pub struct Forest {
krate: Crate,
pub dep_graph: DepGraph,
inlined_bodies: SyncTypedArena<Body>
}

impl Forest {
pub fn new(krate: Crate, dep_graph: &DepGraph) -> Forest {
Forest {
krate,
dep_graph: dep_graph.clone(),
inlined_bodies: SyncTypedArena::new()
}
}

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

definitions: &'hir Definitions,

/// Bodies inlined from other crates are cached here.
inlined_bodies: Lock<DefIdMap<&'hir Body>>,

/// The reverse mapping of `node_to_hir_id`.
hir_to_node_id: FxHashMap<HirId, NodeId>,
}
Expand Down Expand Up @@ -923,21 +915,6 @@ impl<'hir> Map<'hir> {
}
}

pub fn get_inlined_body_untracked(&self, def_id: DefId) -> Option<&'hir Body> {
self.inlined_bodies.borrow().get(&def_id).cloned()
}

pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'hir Body {
let mut inlined_bodies = self.inlined_bodies.borrow_mut();
if let Some(&b) = inlined_bodies.get(&def_id) {
debug_assert_eq!(&body, b);
return b;
}
let body = self.forest.inlined_bodies.alloc(body);
inlined_bodies.insert(def_id, body);
body
}

/// Returns the name associated with the given NodeId's AST.
pub fn name(&self, id: NodeId) -> Name {
match self.get(id) {
Expand Down Expand Up @@ -1195,7 +1172,6 @@ pub fn map_crate<'hir>(sess: &::session::Session,
map,
hir_to_node_id,
definitions,
inlined_bodies: Lock::new(DefIdMap()),
};

hir_id_validator::check_crate(&map);
Expand Down
28 changes: 0 additions & 28 deletions src/librustc/ich/impls_cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
//! This module contains `HashStable` implementations for various data types
//! from rustc::middle::cstore in no particular order.
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};

use middle;

impl_stable_hash_for!(enum middle::cstore::DepKind {
Expand Down Expand Up @@ -64,29 +62,3 @@ impl_stable_hash_for!(struct middle::cstore::CrateSource {
rlib,
rmeta
});

impl<HCX> HashStable<HCX> for middle::cstore::ExternBodyNestedBodies {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut HCX,
hasher: &mut StableHasher<W>) {
let middle::cstore::ExternBodyNestedBodies {
nested_bodies: _,
fingerprint,
} = *self;

fingerprint.hash_stable(hcx, hasher);
}
}

impl<'a, HCX> HashStable<HCX> for middle::cstore::ExternConstBody<'a> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut HCX,
hasher: &mut StableHasher<W>) {
let middle::cstore::ExternConstBody {
body: _,
fingerprint,
} = *self;

fingerprint.hash_stable(hcx, hasher);
}
}
23 changes: 0 additions & 23 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,16 @@
//! are *mostly* used as a part of that interface, but these should
//! probably get a better home if someone can find one.
use hir;
use hir::def;
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use hir::map as hir_map;
use hir::map::definitions::{Definitions, DefKey, DefPathTable};
use hir::svh::Svh;
use ich;
use ty::{self, TyCtxt};
use session::{Session, CrateDisambiguator};
use session::search_paths::PathKind;

use std::any::Any;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use syntax::ast;
use syntax::ext::base::SyntaxExtension;
Expand Down Expand Up @@ -209,26 +206,6 @@ pub trait MetadataLoader {
-> Result<MetadataRef, String>;
}

#[derive(Clone)]
pub struct ExternConstBody<'tcx> {
pub body: &'tcx hir::Body,

// It would require a lot of infrastructure to enable stable-hashing Bodies
// from other crates, so we hash on export and just store the fingerprint
// with them.
pub fingerprint: ich::Fingerprint,
}

#[derive(Clone)]
pub struct ExternBodyNestedBodies {
pub nested_bodies: Lrc<BTreeMap<hir::BodyId, hir::Body>>,

// It would require a lot of infrastructure to enable stable-hashing Bodies
// from other crates, so we hash on export and just store the fingerprint
// with them.
pub fingerprint: ich::Fingerprint,
}

/// A store of Rust crates, through with their metadata
/// can be accessed.
///
Expand Down
6 changes: 0 additions & 6 deletions src/librustc/ty/maps/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> {
}
}

impl<'tcx> QueryDescription<'tcx> for queries::item_body_nested_bodies<'tcx> {
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
}
}

impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> {
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
format!("const checking if rvalue is promotable to static `{}`",
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/maps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ use hir::svh::Svh;
use infer::canonical::{self, Canonical};
use lint;
use middle::borrowck::BorrowCheckResult;
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary,
ExternBodyNestedBodies, ForeignModule};
use middle::cstore::{NativeLibraryKind, DepKind, CrateSource, ExternConstBody};
use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule};
use middle::cstore::{NativeLibraryKind, DepKind, CrateSource};
use middle::privacy::AccessLevels;
use middle::reachable::ReachableSet;
use middle::region;
Expand Down Expand Up @@ -254,9 +253,11 @@ define_maps! { <'tcx>
[] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
[] fn trans_fn_attrs: trans_fn_attrs(DefId) -> TransFnAttrs,
[] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
/// Gets the rendered value of the specified constant or associated constant.
/// Used by rustdoc.
[] fn rendered_const: RenderedConst(DefId) -> String,
[] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
[] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
[] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> ExternBodyNestedBodies,
[] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
[] fn rvalue_promotable_map: RvaluePromotableMap(DefId) -> Lrc<ItemLocalSet>,
[] fn is_mir_available: IsMirAvailable(DefId) -> bool,
Expand Down Expand Up @@ -376,7 +377,6 @@ define_maps! { <'tcx>
[] fn get_lang_items: get_lang_items_node(CrateNum) -> Lrc<LanguageItems>,
[] fn defined_lang_items: DefinedLangItems(CrateNum) -> Lrc<Vec<(DefId, usize)>>,
[] fn missing_lang_items: MissingLangItems(CrateNum) -> Lrc<Vec<LangItem>>,
[] fn extern_const_body: ExternConstBody(DefId) -> ExternConstBody<'tcx>,
[] fn visible_parent_map: visible_parent_map_node(CrateNum)
-> Lrc<DefIdMap<DefId>>,
[] fn missing_extern_crate_item: MissingExternCrateItem(CrateNum) -> bool,
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/ty/maps/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind::LookupDeprecationEntry => {
force!(lookup_deprecation_entry, def_id!());
}
DepKind::ItemBodyNestedBodies => { force!(item_body_nested_bodies, def_id!()); }
DepKind::ConstIsRvaluePromotableToStatic => {
force!(const_is_rvalue_promotable_to_static, def_id!());
}
Expand All @@ -1063,6 +1062,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind::ItemAttrs => { force!(item_attrs, def_id!()); }
DepKind::TransFnAttrs => { force!(trans_fn_attrs, def_id!()); }
DepKind::FnArgNames => { force!(fn_arg_names, def_id!()); }
DepKind::RenderedConst => { force!(rendered_const, def_id!()); }
DepKind::DylibDepFormats => { force!(dylib_dependency_formats, krate!()); }
DepKind::IsPanicRuntime => { force!(is_panic_runtime, krate!()); }
DepKind::IsCompilerBuiltins => { force!(is_compiler_builtins, krate!()); }
Expand Down Expand Up @@ -1119,7 +1119,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind::GetLangItems => { force!(get_lang_items, LOCAL_CRATE); }
DepKind::DefinedLangItems => { force!(defined_lang_items, krate!()); }
DepKind::MissingLangItems => { force!(missing_lang_items, krate!()); }
DepKind::ExternConstBody => { force!(extern_const_body, def_id!()); }
DepKind::VisibleParentMap => { force!(visible_parent_map, LOCAL_CRATE); }
DepKind::MissingExternCrateItem => {
force!(missing_extern_crate_item, krate!());
Expand Down
96 changes: 0 additions & 96 deletions src/librustc_metadata/astencode.rs

This file was deleted.

8 changes: 1 addition & 7 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
mir_const_qualif => {
(cdata.mir_const_qualif(def_id.index), Lrc::new(IdxSetBuf::new_empty(0)))
}
typeck_tables_of => { cdata.item_body_tables(def_id.index, tcx) }
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
is_const_fn => { cdata.is_const_fn(def_id.index) }
Expand All @@ -161,9 +160,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
// This is only used by rustdoc anyway, which shouldn't have
// incremental recompilation ever enabled.
fn_arg_names => { cdata.get_fn_arg_names(def_id.index) }
rendered_const => { cdata.get_rendered_const(def_id.index) }
impl_parent => { cdata.get_parent_impl(def_id.index) }
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
item_body_nested_bodies => { cdata.item_body_nested_bodies(tcx, def_id.index) }
const_is_rvalue_promotable_to_static => {
cdata.const_is_rvalue_promotable_to_static(def_id.index)
}
Expand Down Expand Up @@ -243,11 +242,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
defined_lang_items => { Lrc::new(cdata.get_lang_items()) }
missing_lang_items => { Lrc::new(cdata.get_missing_lang_items()) }

extern_const_body => {
debug!("item_body({:?}): inlining item", def_id);
cdata.extern_const_body(tcx, def_id.index)
}

missing_extern_crate_item => {
let r = match *cdata.extern_crate.borrow() {
Some(extern_crate) if !extern_crate.direct => true,
Expand Down
Loading

0 comments on commit 1a44439

Please sign in to comment.