Skip to content

Rollup of 10 pull requests #73504

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

Merged
merged 47 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a6127e3
Merge pull request #1 from rust-lang/master
richkadel May 22, 2020
d1c275b
linker: MSVC supports linking static libraries as a whole archive
petrochenkov May 30, 2020
d139a72
Merge pull request #2 from rust-lang/master
richkadel Jun 10, 2020
d40e624
compiletest: Add directives to detect sanitizer support
tmiasko Jun 5, 2020
0687b78
Speed up bootstrap a little.
ehuss Jun 13, 2020
607e851
Switch bootstrap metadata to --no-deps.
ehuss Jun 14, 2020
5393a29
Move convert_place_derefs_to_mutable out from check/method/confirm.rs
nbdd0121 May 16, 2020
fb0793c
Add some comments to librustc_typeck/check/callee.rs
nbdd0121 Jun 14, 2020
c2b920f
Show suite paths (`src/test/ui/...`) in help output.
ehuss Jun 14, 2020
f17fd7b
Add some doc comments regarding PathSet.
ehuss Jun 15, 2020
8121d2e
Fix up autoderef when performing mutable auto borrow
nbdd0121 Jun 14, 2020
4710f85
Add ui tests for issue 68590 and 72225
nbdd0121 Jun 14, 2020
d6156e8
Change how compiler-builtins gets many CGUs
alexcrichton Jun 8, 2020
e390acd
Use expr_ty_adjusted in convert_place_op_to_mutable
nbdd0121 Jun 15, 2020
8e7606f
bootstrap/install.rs: support a nonexistent `prefix` in `x.py install`
nodakai Jun 14, 2020
5cedf5d
Refactor usage of Needs in typeck
nbdd0121 Jun 15, 2020
395256a
Merge pull request #3 from rust-lang/master
richkadel Jun 15, 2020
5068ae1
[WIP] injects llvm intrinsic instrprof.increment for coverage reports
richkadel Jun 4, 2020
088037a
explained lang_item function body (count_code_region)
richkadel Jun 5, 2020
2c5c2a6
removed experiments for cleaner github PR
richkadel Jun 5, 2020
d2cd59a
Add case for count_code_region() extern lang_item
richkadel Jun 5, 2020
e4df7e7
Update src/libcore/intrinsics.rs
richkadel Jun 5, 2020
7e49a9e
moved to post_borrowck_cleanup & used MirPatch
richkadel Jun 8, 2020
46ebd57
moved instrument_coverage pass, optimized scalar, added FIXME
richkadel Jun 8, 2020
20aba8f
added test, Operand::const_from_scalar, require_lang_item, & comments
richkadel Jun 10, 2020
163e585
updated mir-opt test due to other recent changes to MIR
richkadel Jun 10, 2020
98685a4
Add new `fn_span` to TerminatorKind::Call instance
richkadel Jun 16, 2020
93022be
bootstrap: read config from $RUST_BOOTSTRAP_CONFIG
davidtwco Jun 13, 2020
a19dfb5
Create new E0763 error code for unterminated byte constant
GuillaumeGomez Jun 12, 2020
bad252c
Update ui tests
GuillaumeGomez Jun 12, 2020
f0a4233
memory access sanity checks: abort instead of panic
RalfJung Jun 6, 2020
81c7ebd
we can enable one more codegen test in debug mode now
RalfJung Jun 6, 2020
2b7d858
Add some comments related to place op typeck
nbdd0121 Jun 16, 2020
1db44af
Ensure profiling runtime for -Zinstrument-coverage
richkadel Jun 17, 2020
c338729
Update src/libcore/intrinsics.rs
richkadel Jun 17, 2020
b9f0304
temporarily enable mac and windows tests on bors try
richkadel Jun 17, 2020
36c9014
removed try config to test mac & windows (passed)
richkadel Jun 17, 2020
70622db
Rollup merge of #72280 - nbdd0121:typeck, r=nikomatsakis
RalfJung Jun 19, 2020
7cc4518
Rollup merge of #72785 - petrochenkov:wholemsvc, r=matthewjasper
RalfJung Jun 19, 2020
1dc6c3c
Rollup merge of #73011 - richkadel:llvm-count-from-mir-pass, r=tmandry
RalfJung Jun 19, 2020
0851036
Rollup merge of #73044 - tmiasko:compiletest-san, r=nikomatsakis
RalfJung Jun 19, 2020
125c196
Rollup merge of #73054 - RalfJung:dont-panic, r=Mark-Simulacrum
RalfJung Jun 19, 2020
1e31a7c
Rollup merge of #73136 - alexcrichton:thinlto-compiler-builtins, r=Ma…
RalfJung Jun 19, 2020
45aa36b
Rollup merge of #73280 - GuillaumeGomez:add-e0763, r=petrochenkov
RalfJung Jun 19, 2020
0404788
Rollup merge of #73317 - davidtwco:bootstrap-config-env-var, r=Mark-S…
RalfJung Jun 19, 2020
a59d164
Rollup merge of #73350 - nodakai:install-rs-support-nonexistent-prefi…
RalfJung Jun 19, 2020
61c8925
Rollup merge of #73352 - ehuss:bootstrap-metadata, r=Mark-Simulacrum
RalfJung Jun 19, 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
Prev Previous commit
Next Next commit
Add case for count_code_region() extern lang_item
As suggested in PR feedback:

#73011 (comment)

This allows count_code_region() to be handled like a normal intrinsic so
the InstanceDef::InjectedCode variant is no longer needed.
  • Loading branch information
richkadel committed Jun 15, 2020
commit d2cd59a0315809afa58df0196c34b33ee0a8c161
21 changes: 6 additions & 15 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1941,22 +1941,13 @@ extern "rust-intrinsic" {
///
/// Perma-unstable: do not use.
pub fn miri_start_panic(payload: *mut u8) -> !;
}

/// Defines the `count_code_region` intrinsic as a `LangItem`. `LangItem`s require a function body
/// to register its DefId with the LangItem entry. The function body is never actually called (and
/// is therefore implemented as an aborting stub) because it is replaced with the LLVM intrinsic
/// `llvm.instrprof.increment` by
/// `rustc_codegen_llvm::intrinsic::IntrinsicCallMethods::codegen_intrinsic_call()`.
#[cfg(not(bootstrap))]
#[cfg_attr(not(bootstrap), lang = "count_code_region")]
fn count_code_region(_index: u32) {
// remove `unsafe` (and safety comment) on bootstrap bump
#[cfg_attr(not(bootstrap), allow(unused_unsafe))]
// SAFETY: the `abort` intrinsic has no requirements to be called.
unsafe {
abort()
}
/// Internal placeholder for injecting code coverage counters when the "instrument-coverage"
/// option is enabled. The placeholder is replaced with `llvm.instrprof.increment` during code
/// generation.
#[cfg(not(bootstrap))]
#[cfg_attr(not(bootstrap), lang = "count_code_region")]
pub fn count_code_region(_index: u32);
}

// Some functions are defined here because they accidentally got made
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {

// Handle intrinsics old codegen wants Expr's for, ourselves.
let intrinsic = match def {
Some(ty::InstanceDef::Intrinsic(def_id))
| Some(ty::InstanceDef::InjectedCode(def_id)) => {
Some(bx.tcx().item_name(def_id).as_str())
}
Some(ty::InstanceDef::Intrinsic(def_id)) => Some(bx.tcx().item_name(def_id).as_str()),
_ => None,
};
let intrinsic = intrinsic.as_ref().map(|s| &s[..]);
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ impl<'tcx> CodegenUnit<'tcx> {
InstanceDef::VtableShim(..)
| InstanceDef::ReifyShim(..)
| InstanceDef::Intrinsic(..)
| InstanceDef::InjectedCode(..)
| InstanceDef::FnPtrShim(..)
| InstanceDef::Virtual(..)
| InstanceDef::ClosureOnceShim { .. }
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_middle/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ pub enum InstanceDef<'tcx> {
Item(DefId),
Intrinsic(DefId),

/// Injected call to a placeholder function that is replaced with
/// For example: `core::intrinsic::count_code_region()` for code coverage.
InjectedCode(DefId),

/// `<T as Trait>::method` where `method` receives unsizeable `self: Self`.
VtableShim(DefId),

Expand Down Expand Up @@ -153,7 +149,6 @@ impl<'tcx> InstanceDef<'tcx> {
| InstanceDef::FnPtrShim(def_id, _)
| InstanceDef::Virtual(def_id, _)
| InstanceDef::Intrinsic(def_id)
| InstanceDef::InjectedCode(def_id)
| InstanceDef::ClosureOnceShim { call_once: def_id }
| InstanceDef::DropGlue(def_id, _)
| InstanceDef::CloneShim(def_id, _) => def_id,
Expand Down Expand Up @@ -241,7 +236,6 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
InstanceDef::VtableShim(_) => write!(f, " - shim(vtable)"),
InstanceDef::ReifyShim(_) => write!(f, " - shim(reify)"),
InstanceDef::Intrinsic(_) => write!(f, " - intrinsic"),
InstanceDef::InjectedCode(_) => write!(f, " - injected-code"),
InstanceDef::Virtual(_, num) => write!(f, " - virtual#{}", num),
InstanceDef::FnPtrShim(_, ty) => write!(f, " - shim({:?})", ty),
InstanceDef::ClosureOnceShim { .. } => write!(f, " - shim"),
Expand Down Expand Up @@ -421,7 +415,6 @@ impl<'tcx> Instance<'tcx> {
| InstanceDef::FnPtrShim(..)
| InstanceDef::Item(_)
| InstanceDef::Intrinsic(..)
| InstanceDef::InjectedCode(..)
| InstanceDef::ReifyShim(..)
| InstanceDef::Virtual(..)
| InstanceDef::VtableShim(..) => Some(self.substs),
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2717,7 +2717,6 @@ impl<'tcx> TyCtxt<'tcx> {
ty::InstanceDef::VtableShim(..)
| ty::InstanceDef::ReifyShim(..)
| ty::InstanceDef::Intrinsic(..)
| ty::InstanceDef::InjectedCode(..)
| ty::InstanceDef::FnPtrShim(..)
| ty::InstanceDef::Virtual(..)
| ty::InstanceDef::ClosureOnceShim { .. }
Expand Down
11 changes: 3 additions & 8 deletions src/librustc_middle/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
ty::InstanceDef::VtableShim(def_id) => Some(ty::InstanceDef::VtableShim(def_id)),
ty::InstanceDef::ReifyShim(def_id) => Some(ty::InstanceDef::ReifyShim(def_id)),
ty::InstanceDef::Intrinsic(def_id) => Some(ty::InstanceDef::Intrinsic(def_id)),
ty::InstanceDef::InjectedCode(def_id) => Some(ty::InstanceDef::Intrinsic(def_id)),
ty::InstanceDef::FnPtrShim(def_id, ref ty) => {
Some(ty::InstanceDef::FnPtrShim(def_id, tcx.lift(ty)?))
}
Expand Down Expand Up @@ -847,7 +846,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
VtableShim(did) => VtableShim(did.fold_with(folder)),
ReifyShim(did) => ReifyShim(did.fold_with(folder)),
Intrinsic(did) => Intrinsic(did.fold_with(folder)),
InjectedCode(did) => InjectedCode(did.fold_with(folder)),
FnPtrShim(did, ty) => FnPtrShim(did.fold_with(folder), ty.fold_with(folder)),
Virtual(did, i) => Virtual(did.fold_with(folder), i),
ClosureOnceShim { call_once } => {
Expand All @@ -863,12 +861,9 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
use crate::ty::InstanceDef::*;
self.substs.visit_with(visitor)
|| match self.def {
Item(did)
| VtableShim(did)
| ReifyShim(did)
| Intrinsic(did)
| InjectedCode(did)
| Virtual(did, _) => did.visit_with(visitor),
Item(did) | VtableShim(did) | ReifyShim(did) | Intrinsic(did) | Virtual(did, _) => {
did.visit_with(visitor)
}
FnPtrShim(did, ty) | CloneShim(did, ty) => {
did.visit_with(visitor) || ty.visit_with(visitor)
}
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_mir/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic);
M::call_intrinsic(self, instance, args, ret, unwind)
}
ty::InstanceDef::InjectedCode(..) => {
M::call_intrinsic(self, instance, args, ret, unwind)
}
ty::InstanceDef::VtableShim(..)
| ty::InstanceDef::ReifyShim(..)
| ty::InstanceDef::ClosureOnceShim { .. }
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,7 @@ fn visit_instance_use<'tcx>(
}

match instance.def {
ty::InstanceDef::Virtual(..)
| ty::InstanceDef::Intrinsic(_)
| ty::InstanceDef::InjectedCode(_) => {
ty::InstanceDef::Virtual(..) | ty::InstanceDef::Intrinsic(_) => {
if !is_direct_call {
bug!("{:?} being reified", instance);
}
Expand Down Expand Up @@ -753,7 +751,6 @@ fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx
| ty::InstanceDef::FnPtrShim(..)
| ty::InstanceDef::DropGlue(..)
| ty::InstanceDef::Intrinsic(_)
| ty::InstanceDef::InjectedCode(_)
| ty::InstanceDef::CloneShim(..) => return true,
};

Expand Down
2 changes: 0 additions & 2 deletions src/librustc_mir/monomorphize/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ fn mono_item_visibility(
| InstanceDef::FnPtrShim(..)
| InstanceDef::Virtual(..)
| InstanceDef::Intrinsic(..)
| InstanceDef::InjectedCode(..)
| InstanceDef::ClosureOnceShim { .. }
| InstanceDef::DropGlue(..)
| InstanceDef::CloneShim(..) => return Visibility::Hidden,
Expand Down Expand Up @@ -718,7 +717,6 @@ fn characteristic_def_id_of_mono_item<'tcx>(
| ty::InstanceDef::FnPtrShim(..)
| ty::InstanceDef::ClosureOnceShim { .. }
| ty::InstanceDef::Intrinsic(..)
| ty::InstanceDef::InjectedCode(..)
| ty::InstanceDef::DropGlue(..)
| ty::InstanceDef::Virtual(..)
| ty::InstanceDef::CloneShim(..) => return None,
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_mir/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
ty::InstanceDef::Intrinsic(_) => {
bug!("creating shims from intrinsics ({:?}) is unsupported", instance)
}
ty::InstanceDef::InjectedCode(_) => {
bug!("creating shims from injected code ({:?}) is unsupported", instance)
}
};
debug!("make_shim({:?}) = untransformed {:?}", instance, result);

Expand Down
16 changes: 14 additions & 2 deletions src/librustc_passes/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::lang_items;
use rustc_hir::lang_items::ITEM_REFS;
use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS;
use rustc_middle::middle::lang_items::whitelisted;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::CrateType;
use rustc_span::symbol::sym;
use rustc_span::symbol::Symbol;
use rustc_span::Span;

Expand Down Expand Up @@ -70,11 +72,21 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
}

impl<'a, 'tcx> Context<'a, 'tcx> {
fn register(&mut self, name: Symbol, span: Span) {
fn register(&mut self, name: Symbol, span: Span, hir_id: hir::HirId) {
if let Some(&item) = WEAK_ITEMS_REFS.get(&name) {
if self.items.require(item).is_err() {
self.items.missing.push(item);
}
} else if name == sym::count_code_region {
// `core::intrinsics::code_count_region()` is (currently) the only `extern` lang item
// that is never actually linked. It is not a `weak_lang_item` that can be registered
// when used, and should be registered here instead.
if let Some((item_index, _)) = ITEM_REFS.get(&*name.as_str()).cloned() {
if self.items.items[item_index].is_none() {
let item_def_id = self.tcx.hir().local_def_id(hir_id).to_def_id();
self.items.items[item_index] = Some(item_def_id);
}
}
} else {
struct_span_err!(self.tcx.sess, span, E0264, "unknown external lang item: `{}`", name)
.emit();
Expand All @@ -91,7 +103,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {

fn visit_foreign_item(&mut self, i: &hir::ForeignItem<'_>) {
if let Some((lang_item, _)) = hir::lang_items::extract(&i.attrs) {
self.register(lang_item, i.span);
self.register(lang_item, i.span, i.hir_id);
}
intravisit::walk_foreign_item(self, i)
}
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ fn resolve_instance<'tcx>(
debug!(" => intrinsic");
ty::InstanceDef::Intrinsic(def_id)
}
ty::FnDef(def_id, _) if Some(def_id) == tcx.lang_items().count_code_region_fn() => {
debug!(" => injected placeholder function to be replaced");
ty::InstanceDef::InjectedCode(def_id)
}
ty::FnDef(def_id, substs) if Some(def_id) == tcx.lang_items().drop_in_place_fn() => {
let ty = substs.type_at(0);

Expand Down
2 changes: 2 additions & 0 deletions src/librustc_typeck/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
return;
}

"count_code_region" => (0, vec![tcx.types.u32], tcx.mk_unit()),

ref other => {
struct_span_err!(
tcx.sess,
Expand Down