Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #70211

Merged
merged 25 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
afa940b
Update the mir inline costs
andjo403 Mar 11, 2020
f8870bf
Build dist-android with --enable-profiler
Mar 16, 2020
63811bc
rustc_infer: remove InferCtxt::closure_sig as the FnSig is always sha…
eddyb Mar 18, 2020
50c0562
Remove -ffreestanding from libprofiler_builtins because we do need th…
Mar 18, 2020
a39875b
do not 'return' in 'throw_' macros
RalfJung Mar 19, 2020
e8f1dfa
hir: replace "items" terminology with "nodes" where appropriate.
eddyb Mar 18, 2020
6cd0dca
Prefetch queries used by the metadata encoder
Zoxc Jan 4, 2020
1a34cbc
Encode exported symbols last
Zoxc Jan 11, 2020
03af82b
Prefetch exported symbols
Zoxc Jan 11, 2020
3d59c0e
Make the timer more verbose
Zoxc Jan 11, 2020
a2bca90
Make metadata prefetching more accurate
Zoxc Jan 13, 2020
801e442
Add some comments
Zoxc Mar 14, 2020
027c8d9
Use `assert_ignored` when encoding metadata
Zoxc Mar 14, 2020
203bb2b
Update stdarch submodule
Amanieu Mar 19, 2020
be9679d
rustc/query: tweak comments on hir_owner{,_nodes}.
eddyb Mar 18, 2020
2d75a33
Refactorings to begin getting rid of rustc_codegen_utils
mark-i-m Mar 12, 2020
e46b3c2
more type annotations to help inference
RalfJung Mar 20, 2020
9adfb18
Rollup merge of #67888 - Zoxc:metadata-prefetch, r=matthewjasper
Centril Mar 21, 2020
426a4cc
Rollup merge of #69934 - andjo403:inlinecost, r=wesleywiser
Centril Mar 21, 2020
0b99489
Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddyb
Centril Mar 21, 2020
bbd1ca3
Rollup merge of #70054 - rojamd:android-pgo, r=michaelwoerister
Centril Mar 21, 2020
a6d0c35
Rollup merge of #70089 - eddyb:closure-sig-infer, r=nikomatsakis
Centril Mar 21, 2020
569272a
Rollup merge of #70092 - eddyb:hir-items-are-just-nodes, r=Zoxc
Centril Mar 21, 2020
16f607f
Rollup merge of #70138 - RalfJung:throw-not-return, r=oli-obk
Centril Mar 21, 2020
744bcc6
Rollup merge of #70151 - Amanieu:stdarch, r=sfackler
Centril Mar 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3567,7 +3567,6 @@ dependencies = [
"rustc_ast",
"rustc_attr",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
Expand Down Expand Up @@ -3598,37 +3597,21 @@ dependencies = [
"rustc_apfloat",
"rustc_ast",
"rustc_attr",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_fs_util",
"rustc_hir",
"rustc_incremental",
"rustc_index",
"rustc_metadata",
"rustc_session",
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
"serialize",
"tempfile",
]

[[package]]
name = "rustc_codegen_utils"
version = "0.0.0"
dependencies = [
"log",
"punycode",
"rustc",
"rustc-demangle",
"rustc_ast",
"rustc_data_structures",
"rustc_hir",
"rustc_metadata",
"rustc_session",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_data_structures"
version = "0.0.0"
Expand Down Expand Up @@ -3665,7 +3648,6 @@ dependencies = [
"rustc_ast",
"rustc_ast_pretty",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -3814,7 +3796,6 @@ dependencies = [
"rustc_builtin_macros",
"rustc_codegen_llvm",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
Expand All @@ -3832,6 +3813,7 @@ dependencies = [
"rustc_resolve",
"rustc_session",
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
Expand Down Expand Up @@ -4071,7 +4053,6 @@ dependencies = [
"rustc",
"rustc_ast",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_hir",
"rustc_parse",
Expand Down Expand Up @@ -4112,6 +4093,23 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "rustc_symbol_mangling"
version = "0.0.0"
dependencies = [
"log",
"punycode",
"rustc",
"rustc-demangle",
"rustc_ast",
"rustc_data_structures",
"rustc_hir",
"rustc_metadata",
"rustc_session",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_target"
version = "0.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/dist-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ENV TARGETS=$TARGETS,x86_64-linux-android

ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-profiler \
--arm-linux-androideabi-ndk=/android/ndk/arm-14 \
--armv7-linux-androideabi-ndk=/android/ndk/arm-14 \
--thumbv7neon-linux-androideabi-ndk=/android/ndk/arm-14 \
Expand Down
1 change: 0 additions & 1 deletion src/libprofiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fn main() {
cfg.flag("-fno-builtin");
cfg.flag("-fvisibility=hidden");
cfg.flag("-fomit-frame-pointer");
cfg.flag("-ffreestanding");
cfg.define("VISIBILITY_HIDDEN", None);
if !target.contains("windows") {
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ macro_rules! arena_types {
// HIR query types
[few] indexed_hir: rustc::hir::map::IndexedHir<$tcx>,
[few] hir_definitions: rustc::hir::map::definitions::Definitions,
[] hir_owner: rustc::hir::HirOwner<$tcx>,
[] hir_owner_items: rustc::hir::HirOwnerItems<$tcx>,
[] hir_owner: rustc::hir::Owner<$tcx>,
[] hir_owner_nodes: rustc::hir::OwnerNodes<$tcx>,
], $tcx);
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl DepGraph {
// bug that must be fixed before removing this.
match dep_dep_node.kind {
DepKind::hir_owner
| DepKind::hir_owner_items
| DepKind::hir_owner_nodes
| DepKind::CrateMetadata => {
if let Some(def_id) = dep_dep_node.extract_def_id(tcx) {
if def_id_corresponds_to_hir_dep_node(tcx, def_id) {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::arena::Arena;
use crate::hir::map::definitions::{self, DefPathHash};
use crate::hir::map::{Entry, HirOwnerData, Map};
use crate::hir::{HirItem, HirOwner, HirOwnerItems};
use crate::hir::{Owner, OwnerNodes, ParentedNode};
use crate::ich::StableHashingContext;
use crate::middle::cstore::CrateStore;
use rustc_data_structures::fingerprint::Fingerprint;
Expand Down Expand Up @@ -203,30 +203,30 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
let data = &mut self.map[id.owner];

if data.with_bodies.is_none() {
data.with_bodies = Some(arena.alloc(HirOwnerItems {
data.with_bodies = Some(arena.alloc(OwnerNodes {
hash,
items: IndexVec::new(),
nodes: IndexVec::new(),
bodies: FxHashMap::default(),
}));
}

let items = data.with_bodies.as_mut().unwrap();
let nodes = data.with_bodies.as_mut().unwrap();

if i == 0 {
// Overwrite the dummy hash with the real HIR owner hash.
items.hash = hash;
nodes.hash = hash;

// FIXME: feature(impl_trait_in_bindings) broken and trigger this assert
//assert!(data.signature.is_none());

data.signature =
Some(self.arena.alloc(HirOwner { parent: entry.parent, node: entry.node }));
Some(self.arena.alloc(Owner { parent: entry.parent, node: entry.node }));
} else {
assert_eq!(entry.parent.owner, id.owner);
insert_vec_map(
&mut items.items,
&mut nodes.nodes,
id.local_id,
HirItem { parent: entry.parent.local_id, node: entry.node },
ParentedNode { parent: entry.parent.local_id, node: entry.node },
);
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use self::definitions::{
DefKey, DefPath, DefPathData, DefPathHash, Definitions, DisambiguatedDefPathData,
};

use crate::hir::{HirOwner, HirOwnerItems};
use crate::hir::{Owner, OwnerNodes};
use crate::ty::query::Providers;
use crate::ty::TyCtxt;
use rustc_ast::ast::{self, Name, NodeId};
Expand Down Expand Up @@ -130,8 +130,8 @@ fn is_body_owner<'hir>(node: Node<'hir>, hir_id: HirId) -> bool {
}

pub(super) struct HirOwnerData<'hir> {
pub(super) signature: Option<&'hir HirOwner<'hir>>,
pub(super) with_bodies: Option<&'hir mut HirOwnerItems<'hir>>,
pub(super) signature: Option<&'hir Owner<'hir>>,
pub(super) with_bodies: Option<&'hir mut OwnerNodes<'hir>>,
}

pub struct IndexedHir<'hir> {
Expand Down Expand Up @@ -345,9 +345,12 @@ impl<'hir> Map<'hir> {
let owner = self.tcx.hir_owner(id.owner);
Entry { parent: owner.parent, node: owner.node }
} else {
let owner = self.tcx.hir_owner_items(id.owner);
let item = owner.items[id.local_id].as_ref().unwrap();
Entry { parent: HirId { owner: id.owner, local_id: item.parent }, node: item.node }
let owner = self.tcx.hir_owner_nodes(id.owner);
let node = owner.nodes[id.local_id].as_ref().unwrap();
// FIXME(eddyb) use a single generic type insted of having both
// `Entry` and `ParentedNode`, which are effectively the same.
// Alternatively, rewrite code using `Entry` to use `ParentedNode`.
Entry { parent: HirId { owner: id.owner, local_id: node.parent }, node: node.node }
}
}

Expand All @@ -373,7 +376,7 @@ impl<'hir> Map<'hir> {
}

pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
self.tcx.hir_owner_items(id.hir_id.owner).bodies.get(&id.hir_id.local_id).unwrap()
self.tcx.hir_owner_nodes(id.hir_id.owner).bodies.get(&id.hir_id.local_id).unwrap()
}

pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
Expand Down
22 changes: 11 additions & 11 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use rustc_hir::ItemLocalId;
use rustc_hir::Node;
use rustc_index::vec::IndexVec;

pub struct HirOwner<'tcx> {
pub struct Owner<'tcx> {
parent: HirId,
node: Node<'tcx>,
}

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwner<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let HirOwner { parent, node } = self;
let Owner { parent, node } = self;
hcx.while_hashing_hir_bodies(false, |hcx| {
parent.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
Expand All @@ -34,22 +34,22 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwner<'tcx> {
}

#[derive(Clone)]
pub struct HirItem<'tcx> {
pub struct ParentedNode<'tcx> {
parent: ItemLocalId,
node: Node<'tcx>,
}

pub struct HirOwnerItems<'tcx> {
pub struct OwnerNodes<'tcx> {
hash: Fingerprint,
items: IndexVec<ItemLocalId, Option<HirItem<'tcx>>>,
nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>,
bodies: FxHashMap<ItemLocalId, &'tcx Body<'tcx>>,
}

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwnerItems<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OwnerNodes<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
// We ignore the `items` and `bodies` fields since these refer to information included in
// We ignore the `nodes` and `bodies` fields since these refer to information included in
// `hash` which is hashed in the collector and used for the crate hash.
let HirOwnerItems { hash, items: _, bodies: _ } = *self;
let OwnerNodes { hash, nodes: _, bodies: _ } = *self;
hash.hash_stable(hcx, hasher);
}
}
Expand Down Expand Up @@ -79,8 +79,8 @@ pub fn provide(providers: &mut Providers<'_>) {
&tcx.untracked_crate.modules[&module]
};
providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature.unwrap();
providers.hir_owner_items = |tcx, id| {
tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|items| &**items).unwrap()
providers.hir_owner_nodes = |tcx, id| {
tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|nodes| &**nodes).unwrap()
};
map::provide(providers);
}
11 changes: 6 additions & 5 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ macro_rules! err_exhaust {
};
}

// In the `throw_*` macros, avoid `return` to make them work with `try {}`.
#[macro_export]
macro_rules! throw_unsup {
($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_unsup!($($tt)*))? };
}

#[macro_export]
Expand All @@ -58,12 +59,12 @@ macro_rules! throw_unsup_format {

#[macro_export]
macro_rules! throw_inval {
($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_inval!($($tt)*))? };
}

#[macro_export]
macro_rules! throw_ub {
($($tt:tt)*) => { return Err(err_ub!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_ub!($($tt)*))? };
}

#[macro_export]
Expand All @@ -73,13 +74,13 @@ macro_rules! throw_ub_format {

#[macro_export]
macro_rules! throw_exhaust {
($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_exhaust!($($tt)*))? };
}

#[macro_export]
macro_rules! throw_machine_stop {
($($tt:tt)*) => {
return Err($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)).into())
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
};
}

Expand Down
13 changes: 7 additions & 6 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,28 @@ rustc_queries! {
}

// The items in a module.
//
// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
// Avoid calling this query directly.
query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems {
eval_always
desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
}

// An HIR item with a `LocalDefId` that can own other HIR items which do
// not themselves have a `LocalDefId`.
// Gives access to the HIR node for the HIR owner `key`.
//
// This can be conveniently accessed by methods on `tcx.hir()`.
// Avoid calling this query directly.
query hir_owner(key: LocalDefId) -> &'tcx HirOwner<'tcx> {
query hir_owner(key: LocalDefId) -> &'tcx crate::hir::Owner<'tcx> {
eval_always
desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
}

// The HIR items which do not themselves have a `LocalDefId` and are
// owned by another HIR item with a `LocalDefId`.
// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
//
// This can be conveniently accessed by methods on `tcx.hir()`.
// Avoid calling this query directly.
query hir_owner_items(key: LocalDefId) -> &'tcx HirOwnerItems<'tcx> {
query hir_owner_nodes(key: LocalDefId) -> &'tcx crate::hir::OwnerNodes<'tcx> {
eval_always
desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn encode_metadata(self) -> EncodedMetadata {
let _prof_timer = self.prof.generic_activity("generate_crate_metadata");
let _prof_timer = self.prof.verbose_generic_activity("generate_crate_metadata");
self.cstore.encode_metadata(self)
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3148,6 +3148,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
context::provide(providers);
erase_regions::provide(providers);
layout::provide(providers);
super::util::bug::provide(providers);
*providers = ty::query::Providers {
trait_impls_of: trait_def::trait_impls_of_provider,
all_local_trait_impls: trait_def::all_local_trait_impls,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ pub trait PrettyPrinter<'tcx>:

if self.tcx().sess.verbose() {
p!(write(
" closure_kind_ty={:?} closure_sig_ty={:?}",
" closure_kind_ty={:?} closure_sig_as_fn_ptr_ty={:?}",
substs.as_closure().kind_ty(did, self.tcx()),
substs.as_closure().sig_ty(did, self.tcx())
substs.as_closure().sig_as_fn_ptr_ty(did, self.tcx())
));
}

Expand Down
Loading