Rustup to rustc 1.41.0-nightly (6d77e45f0 2019-12-04)

This commit is contained in:
bjorn3 2019-12-05 21:00:57 +01:00
parent f0bb30f8a1
commit c6086a8fd7
8 changed files with 98 additions and 16 deletions

View File

@ -1,5 +1,3 @@
cargo-features = ["profile-overrides"]
[package]
name = "rustc_codegen_cranelift"
version = "0.1.0"

View File

@ -1,6 +1,6 @@
#![feature(
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
untagged_unions, decl_macro, rustc_attrs, transparent_unions
untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits
)]
#![no_core]
#![allow(dead_code)]
@ -76,7 +76,13 @@ unsafe impl<'a, T: ?Sized> Sync for &'a T {}
unsafe impl Sync for [u8; 16] {}
#[lang = "freeze"]
trait Freeze {}
unsafe auto trait Freeze {}
unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
unsafe impl<T: ?Sized> Freeze for *const T {}
unsafe impl<T: ?Sized> Freeze for *mut T {}
unsafe impl<T: ?Sized> Freeze for &T {}
unsafe impl<T: ?Sized> Freeze for &mut T {}
#[lang = "not"]
pub trait Not {
@ -538,3 +544,10 @@ pub macro line() { /* compiler built-in */ }
pub macro cfg() { /* compiler built-in */ }
pub static A_STATIC: u8 = 42;
#[lang = "panic_location"]
struct PanicLocation {
file: &'static str,
line: u32,
column: u32,
}

View File

@ -98,10 +98,9 @@ diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index f4a1783..362b537 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -40,6 +40,8 @@ impl Thread {
@@ -40,5 +40,7 @@ impl Thread {
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>)
-> io::Result<Thread> {
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
+ panic!("Threads are not yet supported, because cranelift doesn't support atomics.");
+
let p = box p;

View File

@ -10,6 +10,69 @@ use crate::prelude::*;
pub use self::returning::codegen_return;
// Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349
pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> {
let ty = instance.ty(tcx);
match ty.kind {
ty::FnDef(..) |
// Shims currently have type FnPtr. Not sure this should remain.
ty::FnPtr(_) => {
let mut sig = ty.fn_sig(tcx);
if let ty::InstanceDef::VtableShim(..) = instance.def {
// Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`.
sig = sig.map_bound(|mut sig| {
let mut inputs_and_output = sig.inputs_and_output.to_vec();
inputs_and_output[0] = tcx.mk_mut_ptr(inputs_and_output[0]);
sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output);
sig
});
}
sig
}
ty::Closure(def_id, substs) => {
let sig = substs.as_closure().sig(def_id, tcx);
let env_ty = tcx.closure_env_ty(def_id, substs).unwrap();
sig.map_bound(|sig| tcx.mk_fn_sig(
std::iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()),
sig.output(),
sig.c_variadic,
sig.unsafety,
sig.abi
))
}
ty::Generator(def_id, substs, _) => {
let sig = substs.as_generator().poly_sig(def_id, tcx);
let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv);
let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty);
let pin_did = tcx.lang_items().pin_type().unwrap();
let pin_adt_ref = tcx.adt_def(pin_did);
let pin_substs = tcx.intern_substs(&[env_ty.into()]);
let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs);
sig.map_bound(|sig| {
let state_did = tcx.lang_items().gen_state().unwrap();
let state_adt_ref = tcx.adt_def(state_did);
let state_substs = tcx.intern_substs(&[
sig.yield_ty.into(),
sig.return_ty.into(),
]);
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
tcx.mk_fn_sig(std::iter::once(env_ty),
ret_ty,
false,
rustc::hir::Unsafety::Normal,
rustc_target::spec::abi::Abi::Rust
)
})
}
_ => bug!("unexpected type {:?} in Instance::fn_sig", ty)
}
}
fn clif_sig_from_fn_sig<'tcx>(
tcx: TyCtxt<'tcx>,
sig: FnSig<'tcx>,
@ -98,7 +161,7 @@ pub fn get_function_name_and_sig<'tcx>(
) -> (String, Signature) {
assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types());
let fn_sig =
tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &inst.fn_sig(tcx));
tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_sig_for_fn_abi(tcx, inst));
if fn_sig.c_variadic && !support_vararg {
unimpl!("Variadic function definitions are not yet supported");
}
@ -199,7 +262,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
fn self_sig(&self) -> FnSig<'tcx> {
self.tcx.normalize_erasing_late_bound_regions(
ParamEnv::reveal_all(),
&self.instance.fn_sig(self.tcx),
&fn_sig_for_fn_abi(self.tcx, self.instance),
)
}

View File

@ -9,7 +9,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
) {
let tcx = cx.tcx;
let mir = tcx.instance_mir(instance.def);
let mir = *tcx.instance_mir(instance.def);
// Declare function
let (name, sig) = get_function_name_and_sig(tcx, instance, false);

View File

@ -5,8 +5,8 @@ use rustc::mir::interpret::{
};
use rustc::ty::{layout::Align, Const, ConstKind};
use rustc_mir::interpret::{
ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup,
StackPopInfo,
ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PanicInfo, PlaceTy, Pointer,
StackPopCleanup, StackPopInfo,
};
use cranelift_module::*;
@ -407,7 +407,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
panic!();
}
fn find_fn(
fn find_mir_or_eval_fn(
_: &mut InterpCx<'mir, 'tcx, Self>,
_: Instance<'tcx>,
_: &[OpTy<'tcx>],
@ -449,7 +449,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
panic!();
}
fn tag_allocation<'b>(
fn init_allocation_extra<'b>(
_: &(),
_: AllocId,
alloc: Cow<'b, Allocation>,
@ -479,6 +479,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter {
fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: (), _: bool) -> InterpResult<'tcx, StackPopInfo> {
Ok(StackPopInfo::Normal)
}
fn assert_panic(
_: &mut InterpCx<'mir, 'tcx, Self>,
_: Span,
_: &PanicInfo<Operand<'tcx>>,
_: Option<BasicBlock>,
) -> InterpResult<'tcx> {
unreachable!()
}
}
pub fn mir_operand_get_const_val<'tcx>(

View File

@ -82,7 +82,7 @@ impl CommentWriter {
"sig {:?}",
tcx.normalize_erasing_late_bound_regions(
ParamEnv::reveal_all(),
&instance.fn_sig(tcx)
&crate::abi::fn_sig_for_fn_abi(tcx, instance)
)
),
String::new(),

View File

@ -67,7 +67,7 @@ $RUSTC example/mod_bench.rs --crate-type bin
pushd simple-raytracer
echo "[BENCH COMPILE] ebobby/simple-raytracer"
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug" \
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \
"RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \
"../cargo.sh build"