about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-12-05 21:00:57 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2019-12-05 21:00:57 +0100
commitc6086a8fd7489fa6cf18b7dd0baf73cf21386c77 (patch)
treec288444224f71063fd78d41eabcfdcd57474d2fb
parentf0bb30f8a1ac6107555dfc8fe830d42f469af7f8 (diff)
downloadrust-c6086a8fd7489fa6cf18b7dd0baf73cf21386c77.tar.gz
rust-c6086a8fd7489fa6cf18b7dd0baf73cf21386c77.zip
Rustup to rustc 1.41.0-nightly (6d77e45f0 2019-12-04)
-rw-r--r--Cargo.toml2
-rw-r--r--example/mini_core.rs17
-rw-r--r--patches/0015-Remove-usage-of-unsized-locals.patch5
-rw-r--r--src/abi/mod.rs67
-rw-r--r--src/base.rs2
-rw-r--r--src/constant.rs17
-rw-r--r--src/pretty_clif.rs2
-rwxr-xr-xtest.sh2
8 files changed, 98 insertions, 16 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1a39e249869..b6e55b35720 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,3 @@
-cargo-features = ["profile-overrides"]
-
 [package]
 name = "rustc_codegen_cranelift"
 version = "0.1.0"
diff --git a/example/mini_core.rs b/example/mini_core.rs
index 1d8942c6ab2..1912cc50a21 100644
--- a/example/mini_core.rs
+++ b/example/mini_core.rs
@@ -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,
+}
diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch
index 14504cce09f..02ecaa7a994 100644
--- a/patches/0015-Remove-usage-of-unsized-locals.patch
+++ b/patches/0015-Remove-usage-of-unsized-locals.patch
@@ -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;
diff --git a/src/abi/mod.rs b/src/abi/mod.rs
index 9e3e4f82a39..31e667095fa 100644
--- a/src/abi/mod.rs
+++ b/src/abi/mod.rs
@@ -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),
         )
     }
 
diff --git a/src/base.rs b/src/base.rs
index 33ae97ef652..7c7dd241263 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -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);
diff --git a/src/constant.rs b/src/constant.rs
index ab099292bf4..dade64b348a 100644
--- a/src/constant.rs
+++ b/src/constant.rs
@@ -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>(
diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs
index 0216ba11c37..f595d384f4f 100644
--- a/src/pretty_clif.rs
+++ b/src/pretty_clif.rs
@@ -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(),
diff --git a/test.sh b/test.sh
index 1211461ac0e..05ba16ea31c 100755
--- a/test.sh
+++ b/test.sh
@@ -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"