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 10 pull requests #73668

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b97487b
Add check for doc alias attribute format
GuillaumeGomez May 30, 2020
2d6267a
Add test for doc alias attribute validation
GuillaumeGomez May 30, 2020
0c5c644
Mention that BTreeMap::new() doesn't allocate
TrolledWoods Jun 1, 2020
7ef9eb3
Merge pull request #4 from rust-lang/master
richkadel Jun 18, 2020
791cccc
Merge pull request #5 from rust-lang/master
richkadel Jun 19, 2020
8c7c84b
code coverage foundation for hash and num_counters
richkadel Jun 18, 2020
8fc2eeb
Use newtype to map from `Local` to `GeneratorSavedLocal`
ecstatic-morse Jun 10, 2020
c178e64
Look for stores between non-conflicting generator saved locals
ecstatic-morse Jun 10, 2020
b2ec645
Incorporate review suggestions
ecstatic-morse Jun 19, 2020
95f8daa
Fix -Z unpretty=everybody_loops
jyn514 Jun 20, 2020
f60513e
Move remaining `NodeId` APIs from `Definitions` to `Resolver`
marmeladema Jun 20, 2020
1d3f49f
Always create a root definition when creating a new `Definitions` obj…
marmeladema Jun 21, 2020
bd4f6f0
Move `next_disambiguator` to `Resolver`
marmeladema Jun 21, 2020
933fe80
num_counters to u32, after implementing TypeFoldable
richkadel Jun 22, 2020
932237b
fix `intrinsics::needs_drop` docs
lcnr Jun 22, 2020
3ed96a6
Point at the call spawn when overflow occurs during monomorphization
Aaron1011 Jun 22, 2020
f4a7938
implemented query for coverage data
richkadel Jun 22, 2020
f84b7e1
Provide context on E0308 involving fn items
estebank Jun 22, 2020
994d9d0
Address remaining feedback items
richkadel Jun 22, 2020
08ec4cb
moves coverage data computation from pass to query
richkadel Jun 23, 2020
3d0192e
PR no longer requires u32 impl TypeFoldable
richkadel Jun 23, 2020
a045140
using "mir_body" (vs "body") in InstrumentCoverage
richkadel Jun 23, 2020
977ce57
Updated query for num_counters to compute from max index
richkadel Jun 23, 2020
0c2b025
rustc: Modernize wasm checks for atomics
alexcrichton Jun 23, 2020
6e8aa1f
review comments: wording and style
estebank Jun 23, 2020
558fd6d
Rollup merge of #72780 - GuillaumeGomez:enforce-doc-alias-check, r=ol…
Manishearth Jun 23, 2020
eb061aa
Rollup merge of #72876 - TrolledWoods:patch-2, r=Dylan-DPC
Manishearth Jun 23, 2020
9ac2c1d
Rollup merge of #73244 - ecstatic-morse:validate-generator-mir, r=tma…
Manishearth Jun 23, 2020
feb1082
Rollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandry
Manishearth Jun 23, 2020
92879b0
Rollup merge of #73523 - jyn514:everybody_loops, r=ecstatic-morse
Manishearth Jun 23, 2020
7345a6c
Rollup merge of #73587 - marmeladema:hir-id-ification-final, r=petroc…
Manishearth Jun 23, 2020
9baefc7
Rollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, r=ec…
Manishearth Jun 23, 2020
9274c3e
Rollup merge of #73614 - lcnr:patch-4, r=Dylan-DPC
Manishearth Jun 23, 2020
07abff5
Rollup merge of #73630 - estebank:fn-item-e0308, r=davidtwco
Manishearth Jun 23, 2020
3b69fe1
Rollup merge of #73665 - alexcrichton:update-wasm-atomics-feature, r=…
Manishearth Jun 23, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4200,6 +4200,7 @@ dependencies = [
"rustc_expand",
"rustc_feature",
"rustc_hir",
"rustc_index",
"rustc_metadata",
"rustc_middle",
"rustc_session",
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ struct MergeIter<K, V, I: Iterator<Item = (K, V)>> {
impl<K: Ord, V> BTreeMap<K, V> {
/// Makes a new empty BTreeMap with a reasonable choice for B.
///
/// Does not allocate anything on its own.
///
/// # Examples
///
/// Basic usage:
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ extern "rust-intrinsic" {
/// implements `Copy`.
///
/// If the actual type neither requires drop glue nor implements
/// `Copy`, then may return `true` or `false`.
/// `Copy`, then the return value of this function is unspecified.
///
/// The stabilized version of this intrinsic is
/// [`std::mem::needs_drop`](../../std/mem/fn.needs_drop.html).
Expand Down
17 changes: 6 additions & 11 deletions src/librustc_ast_lowering/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::ItemKind::Const(ty, body_id)
}
ItemKind::Fn(_, FnSig { ref decl, header }, ref generics, ref body) => {
let fn_def_id = self.resolver.definitions().local_def_id(id);
let fn_def_id = self.resolver.local_def_id(id);
self.with_new_scopes(|this| {
this.current_item = Some(ident.span);

Expand Down Expand Up @@ -342,7 +342,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self_ty: ref ty,
items: ref impl_items,
} => {
let def_id = self.resolver.definitions().local_def_id(id);
let def_id = self.resolver.local_def_id(id);

// Lower the "impl header" first. This ordering is important
// for in-band lifetimes! Consider `'a` here:
Expand Down Expand Up @@ -646,7 +646,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
let def_id = self.resolver.definitions().local_def_id(i.id);
let def_id = self.resolver.local_def_id(i.id);
hir::ForeignItem {
hir_id: self.lower_node_id(i.id),
ident: i.ident,
Expand Down Expand Up @@ -747,7 +747,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
let trait_item_def_id = self.resolver.definitions().local_def_id(i.id);
let trait_item_def_id = self.resolver.local_def_id(i.id);

let (generics, kind) = match i.kind {
AssocItemKind::Const(_, ref ty, ref default) => {
Expand Down Expand Up @@ -812,7 +812,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
let impl_item_def_id = self.resolver.local_def_id(i.id);

let (generics, kind) = match &i.kind {
AssocItemKind::Const(_, ty, expr) => {
Expand Down Expand Up @@ -1320,12 +1320,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
if let Some(def_id) = def_id.as_local() {
for param in &generics.params {
if let GenericParamKind::Type { .. } = param.kind {
if def_id
== self
.resolver
.definitions()
.local_def_id(param.id)
{
if def_id == self.resolver.local_def_id(param.id) {
add_bounds
.entry(param.id)
.or_default()
Expand Down
52 changes: 38 additions & 14 deletions src/librustc_ast_lowering/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
use rustc_hir::definitions::{DefKey, DefPathData, Definitions};
use rustc_hir::intravisit;
use rustc_hir::{ConstArg, GenericArg, ParamName};
use rustc_index::vec::IndexVec;
use rustc_index::vec::{Idx, IndexVec};
use rustc_session::config::nightly_options;
use rustc_session::lint::{builtin::BARE_TRAIT_OBJECTS, BuiltinLintDiagnostics, LintBuffer};
use rustc_session::parse::ParseSess;
Expand Down Expand Up @@ -205,6 +205,19 @@ pub trait Resolver {
fn next_node_id(&mut self) -> NodeId;

fn trait_map(&self) -> &NodeMap<Vec<hir::TraitCandidate>>;

fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId>;

fn local_def_id(&self, node: NodeId) -> LocalDefId;

fn create_def(
&mut self,
parent: LocalDefId,
node_id: ast::NodeId,
data: DefPathData,
expn_id: ExpnId,
span: Span,
) -> LocalDefId;
}

type NtToTokenstream = fn(&Nonterminal, &ParseSess, Span) -> TokenStream;
Expand Down Expand Up @@ -436,7 +449,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
match tree.kind {
UseTreeKind::Simple(_, id1, id2) => {
for &id in &[id1, id2] {
self.lctx.resolver.definitions().create_def_with_parent(
self.lctx.resolver.create_def(
owner,
id,
DefPathData::Misc,
Expand Down Expand Up @@ -488,7 +501,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
| ItemKind::Enum(_, ref generics)
| ItemKind::TyAlias(_, ref generics, ..)
| ItemKind::Trait(_, _, ref generics, ..) => {
let def_id = self.lctx.resolver.definitions().local_def_id(item.id);
let def_id = self.lctx.resolver.local_def_id(item.id);
let count = generics
.params
.iter()
Expand Down Expand Up @@ -564,7 +577,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.map(|(&k, v)| (self.node_id_to_hir_id[k].unwrap(), v.clone()))
.collect();

self.resolver.definitions().init_node_id_to_hir_id_mapping(self.node_id_to_hir_id);
let mut def_id_to_hir_id = IndexVec::default();

for (node_id, hir_id) in self.node_id_to_hir_id.into_iter_enumerated() {
if let Some(def_id) = self.resolver.opt_local_def_id(node_id) {
if def_id_to_hir_id.len() <= def_id.index() {
def_id_to_hir_id.resize(def_id.index() + 1, None);
}
def_id_to_hir_id[def_id] = hir_id;
}
}

self.resolver.definitions().init_def_id_to_hir_id_mapping(def_id_to_hir_id);

hir::Crate {
item: hir::CrateItem { module, attrs, span: c.span },
Expand Down Expand Up @@ -628,7 +652,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
.item_local_id_counters
.insert(owner, HIR_ID_COUNTER_LOCKED)
.unwrap_or_else(|| panic!("no `item_local_id_counters` entry for {:?}", owner));
let def_id = self.resolver.definitions().local_def_id(owner);
let def_id = self.resolver.local_def_id(owner);
self.current_hir_id_owner.push((def_id, counter));
let ret = f(self);
let (new_def_id, new_counter) = self.current_hir_id_owner.pop().unwrap();
Expand Down Expand Up @@ -671,8 +695,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
debug_assert!(local_id != HIR_ID_COUNTER_LOCKED);

*local_id_counter += 1;
let owner = this.resolver.definitions().opt_local_def_id(owner).expect(
"you forgot to call `create_def_with_parent` or are lowering node-IDs \
let owner = this.resolver.opt_local_def_id(owner).expect(
"you forgot to call `create_def` or are lowering node-IDs \
that do not belong to the current owner",
);

Expand Down Expand Up @@ -800,7 +824,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
};

// Add a definition for the in-band lifetime def.
self.resolver.definitions().create_def_with_parent(
self.resolver.create_def(
parent_def_id,
node_id,
DefPathData::LifetimeNs(str_name),
Expand Down Expand Up @@ -1088,7 +1112,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

let impl_trait_node_id = self.resolver.next_node_id();
let parent_def_id = self.current_hir_id_owner.last().unwrap().0;
self.resolver.definitions().create_def_with_parent(
self.resolver.create_def(
parent_def_id,
impl_trait_node_id,
DefPathData::ImplTrait,
Expand Down Expand Up @@ -1154,7 +1178,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let node_id = self.resolver.next_node_id();

// Add a definition for the in-band const def.
self.resolver.definitions().create_def_with_parent(
self.resolver.create_def(
parent_def_id,
node_id,
DefPathData::AnonConst,
Expand Down Expand Up @@ -1339,7 +1363,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
ImplTraitContext::Universal(in_band_ty_params) => {
// Add a definition for the in-band `Param`.
let def_id = self.resolver.definitions().local_def_id(def_node_id);
let def_id = self.resolver.local_def_id(def_node_id);

let hir_bounds = self.lower_param_bounds(
bounds,
Expand Down Expand Up @@ -1428,7 +1452,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// frequently opened issues show.
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);

let opaque_ty_def_id = self.resolver.definitions().local_def_id(opaque_ty_node_id);
let opaque_ty_def_id = self.resolver.local_def_id(opaque_ty_node_id);

self.allocate_hir_id_counter(opaque_ty_node_id);

Expand Down Expand Up @@ -1620,7 +1644,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let def_node_id = self.context.resolver.next_node_id();
let hir_id =
self.context.lower_node_id_with_owner(def_node_id, self.opaque_ty_id);
self.context.resolver.definitions().create_def_with_parent(
self.context.resolver.create_def(
self.parent,
def_node_id,
DefPathData::LifetimeNs(name.ident().name),
Expand Down Expand Up @@ -1870,7 +1894,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::Async, span, None);

let opaque_ty_def_id = self.resolver.definitions().local_def_id(opaque_ty_node_id);
let opaque_ty_def_id = self.resolver.local_def_id(opaque_ty_node_id);

self.allocate_hir_id_counter(opaque_ty_node_id);

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use rustc_middle::bug;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::{self, Lto, OutputType, Passes, SanitizerSet, SwitchWithOptPath};
use rustc_session::Session;
use rustc_span::symbol::sym;
use rustc_span::InnerSpan;
use rustc_target::spec::{CodeModel, RelocModel};

Expand Down Expand Up @@ -140,7 +141,7 @@ pub fn target_machine_factory(
// lower atomic operations to single-threaded operations.
if singlethread
&& sess.target.target.llvm_target.contains("wasm32")
&& features.iter().any(|s| *s == "+atomics")
&& sess.target_features.contains(&sym::atomics)
{
singlethread = false;
}
Expand Down
35 changes: 14 additions & 21 deletions src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
use rustc_middle::ty::{self, Ty};
use rustc_middle::{bug, span_bug};
use rustc_span::Span;
use rustc_span::Symbol;
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
use rustc_target::spec::PanicStrategy;

Expand Down Expand Up @@ -141,26 +140,20 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
self.call(llfn, &[], None)
}
"count_code_region" => {
if let ty::InstanceDef::Item(fn_def_id) = caller_instance.def {
let caller_fn_path = tcx.def_path_str(fn_def_id);
debug!(
"count_code_region to llvm.instrprof.increment(fn_name={})",
caller_fn_path
);

// FIXME(richkadel): (1) Replace raw function name with mangled function name;
// (2) Replace hardcoded `1234` in `hash` with a computed hash (as discussed in)
// the MCP (compiler-team/issues/278); and replace the hardcoded `1` for
// `num_counters` with the actual number of counters per function (when the
// changes are made to inject more than one counter per function).
let (fn_name, _len_val) = self.const_str(Symbol::intern(&caller_fn_path));
let index = args[0].immediate();
let hash = self.const_u64(1234);
let num_counters = self.const_u32(1);
self.instrprof_increment(fn_name, hash, num_counters, index)
} else {
bug!("intrinsic count_code_region: no src.instance");
}
// FIXME(richkadel): The current implementation assumes the MIR for the given
// caller_instance represents a single function. Validate and/or correct if inlining
// and/or monomorphization invalidates these assumptions.
let coverage_data = tcx.coverage_data(caller_instance.def_id());
let mangled_fn = tcx.symbol_name(caller_instance);
let (mangled_fn_name, _len_val) = self.const_str(mangled_fn.name);
let hash = self.const_u64(coverage_data.hash);
let num_counters = self.const_u32(coverage_data.num_counters);
let index = args[0].immediate();
debug!(
"count_code_region to LLVM intrinsic instrprof.increment(fn_name={}, hash={:?}, num_counters={:?}, index={:?})",
mangled_fn.name, hash, num_counters, index
);
self.instrprof_increment(mangled_fn_name, hash, num_counters, index)
}
"va_start" => self.va_start(args[0].immediate()),
"va_end" => self.va_end(args[0].immediate()),
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::archive;
use super::command::Command;
use super::symbol_export;
use rustc_span::symbol::sym;

use std::ffi::{OsStr, OsString};
use std::fs::{self, File};
Expand Down Expand Up @@ -1036,9 +1037,7 @@ impl<'a> WasmLd<'a> {
//
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
// symbols are how the TLS segments are initialized and configured.
let atomics = sess.opts.cg.target_feature.contains("+atomics")
|| sess.target.target.options.features.contains("+atomics");
if atomics {
if sess.target_features.contains(&sym::atomics) {
cmd.arg("--shared-memory");
cmd.arg("--max-memory=1073741824");
cmd.arg("--import-memory");
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ pub fn run_compiler(
compiler.output_file().as_ref().map(|p| &**p),
);
}
trace!("finished pretty-printing");
return early_exit();
}

Expand Down
Loading