about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-07-18 12:10:52 +0200
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-07-18 12:10:52 +0200
commitcff5eed8ef6205a33f93537ac224adcb3f31c0be (patch)
tree5ea281a2fbfa5ecc290b55756047b6921799b795
parentb8aab374644ba5aa269f7d9f9da80fdf4fb33684 (diff)
parent33b297a52543ce7eb7783a9a0b1243e8b50c60f9 (diff)
downloadrust-cff5eed8ef6205a33f93537ac224adcb3f31c0be.tar.gz
rust-cff5eed8ef6205a33f93537ac224adcb3f31c0be.zip
Sync from rust 880416180b0a9ee1141c07d4d17667edb77daebd
-rw-r--r--example/issue-91827-extern-types.rs1
-rw-r--r--patches/0027-sysroot-128bit-atomic-operations.patch32
-rw-r--r--src/allocator.rs2
-rw-r--r--src/base.rs29
-rw-r--r--src/cast.rs2
-rw-r--r--src/constant.rs1
-rw-r--r--src/debuginfo/line_info.rs2
-rw-r--r--src/driver/aot.rs13
-rw-r--r--src/intrinsics/mod.rs15
-rw-r--r--src/lib.rs4
-rw-r--r--src/value_and_place.rs8
11 files changed, 48 insertions, 61 deletions
diff --git a/example/issue-91827-extern-types.rs b/example/issue-91827-extern-types.rs
index cf8fada5320..2ecc8b8238b 100644
--- a/example/issue-91827-extern-types.rs
+++ b/example/issue-91827-extern-types.rs
@@ -6,7 +6,6 @@
 // Regression test for issue #91827.
 
 #![feature(const_ptr_offset_from)]
-#![feature(const_slice_from_raw_parts)]
 #![feature(extern_types)]
 
 use std::ptr::addr_of;
diff --git a/patches/0027-sysroot-128bit-atomic-operations.patch b/patches/0027-sysroot-128bit-atomic-operations.patch
index ce1c6c99b40..77f437974c2 100644
--- a/patches/0027-sysroot-128bit-atomic-operations.patch
+++ b/patches/0027-sysroot-128bit-atomic-operations.patch
@@ -19,7 +19,7 @@ index 092b7cf..158cf71 100644
  #[stable(feature = "integer_atomics_stable", since = "1.34.0")]
  impl RefUnwindSafe for crate::sync::atomic::AtomicI64 {}
 -#[cfg(target_has_atomic_load_store = "128")]
--#[unstable(feature = "integer_atomics", issue = "32976")]
+-#[unstable(feature = "integer_atomics", issue = "99069")]
 -impl RefUnwindSafe for crate::sync::atomic::AtomicI128 {}
 
  #[cfg(target_has_atomic_load_store = "ptr")]
@@ -29,7 +29,7 @@ index 092b7cf..158cf71 100644
  #[stable(feature = "integer_atomics_stable", since = "1.34.0")]
  impl RefUnwindSafe for crate::sync::atomic::AtomicU64 {}
 -#[cfg(target_has_atomic_load_store = "128")]
--#[unstable(feature = "integer_atomics", issue = "32976")]
+-#[unstable(feature = "integer_atomics", issue = "99069")]
 -impl RefUnwindSafe for crate::sync::atomic::AtomicU128 {}
 
  #[cfg(target_has_atomic_load_store = "8")]
@@ -46,14 +46,14 @@ index d9de37e..8293fce 100644
 -atomic_int! {
 -    cfg(target_has_atomic = "128"),
 -    cfg(target_has_atomic_equal_alignment = "128"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
 -    rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
--    unstable(feature = "integer_atomics", issue = "32976"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
 -    cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
 -    "i128",
 -    "#![feature(integer_atomics)]\n\n",
@@ -66,14 +66,14 @@ index d9de37e..8293fce 100644
 -atomic_int! {
 -    cfg(target_has_atomic = "128"),
 -    cfg(target_has_atomic_equal_alignment = "128"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
--    unstable(feature = "integer_atomics", issue = "32976"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
 -    rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
--    unstable(feature = "integer_atomics", issue = "32976"),
+-    unstable(feature = "integer_atomics", issue = "99069"),
 -    cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
 -    "u128",
 -    "#![feature(integer_atomics)]\n\n",
diff --git a/src/allocator.rs b/src/allocator.rs
index c3b99b64263..6d321c7b298 100644
--- a/src/allocator.rs
+++ b/src/allocator.rs
@@ -24,7 +24,7 @@ pub(crate) fn codegen(
             unwind_context,
             kind,
             tcx.lang_items().oom().is_some(),
-            tcx.sess.opts.debugging_opts.oom,
+            tcx.sess.opts.unstable_opts.oom,
         );
         true
     } else {
diff --git a/src/base.rs b/src/base.rs
index 848208963b1..098e04452e6 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -530,6 +530,11 @@ fn codegen_stmt<'tcx>(
                     let val = codegen_operand(fx, operand);
                     lval.write_cvalue(fx, val);
                 }
+                Rvalue::CopyForDeref(place) => {
+                    let cplace = codegen_place(fx, place);
+                    let val = cplace.to_cvalue(fx);
+                    lval.write_cvalue(fx, val)
+                }
                 Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
                     let place = codegen_place(fx, place);
                     let ref_ = place.place_ref(fx, lval.layout());
@@ -662,29 +667,6 @@ fn codegen_stmt<'tcx>(
                             let (ptr, _extra) = operand.load_scalar_pair(fx);
                             lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout))
                         }
-                    } else if let ty::Adt(adt_def, _substs) = from_ty.kind() {
-                        // enum -> discriminant value
-                        assert!(adt_def.is_enum());
-                        match to_ty.kind() {
-                            ty::Uint(_) | ty::Int(_) => {}
-                            _ => unreachable!("cast adt {} -> {}", from_ty, to_ty),
-                        }
-                        let to_clif_ty = fx.clif_type(to_ty).unwrap();
-
-                        let discriminant = crate::discriminant::codegen_get_discriminant(
-                            fx,
-                            operand,
-                            fx.layout_of(operand.layout().ty.discriminant_ty(fx.tcx)),
-                        )
-                        .load_scalar(fx);
-
-                        let res = crate::cast::clif_intcast(
-                            fx,
-                            discriminant,
-                            to_clif_ty,
-                            to_ty.is_signed(),
-                        );
-                        lval.write_cvalue(fx, CValue::by_val(res, dest_layout));
                     } else {
                         let to_clif_ty = fx.clif_type(to_ty).unwrap();
                         let from = operand.load_scalar(fx);
@@ -862,6 +844,7 @@ pub(crate) fn codegen_place<'tcx>(
             PlaceElem::Deref => {
                 cplace = cplace.place_deref(fx);
             }
+            PlaceElem::OpaqueCast(ty) => cplace = cplace.place_opaque_cast(fx, ty),
             PlaceElem::Field(field, _ty) => {
                 cplace = cplace.place_field(fx, field);
             }
diff --git a/src/cast.rs b/src/cast.rs
index e8adf8246d1..bad5d1f08a9 100644
--- a/src/cast.rs
+++ b/src/cast.rs
@@ -144,7 +144,7 @@ pub(crate) fn clif_int_or_float_cast(
             fx.bcx.ins().fcvt_to_uint_sat(to_ty, from)
         };
 
-        if let Some(false) = fx.tcx.sess.opts.debugging_opts.saturating_float_casts {
+        if let Some(false) = fx.tcx.sess.opts.unstable_opts.saturating_float_casts {
             return val;
         }
 
diff --git a/src/constant.rs b/src/constant.rs
index 9ddaa6c4fbf..a18b9da1fdd 100644
--- a/src/constant.rs
+++ b/src/constant.rs
@@ -167,6 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
     }
 
     match const_val {
+        ConstValue::ZeroSized => unreachable!(), // we already handles ZST above
         ConstValue::Scalar(x) => match x {
             Scalar::Int(int) => {
                 if fx.clif_type(layout.ty).is_some() {
diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs
index 476d6a54e12..bbcb9591373 100644
--- a/src/debuginfo/line_info.rs
+++ b/src/debuginfo/line_info.rs
@@ -140,7 +140,7 @@ impl<'tcx> DebugContext<'tcx> {
             // In order to have a good line stepping behavior in debugger, we overwrite debug
             // locations of macro expansions with that of the outermost expansion site
             // (unless the crate is being compiled with `-Z debug-macros`).
-            let span = if !span.from_expansion() || tcx.sess.opts.debugging_opts.debug_macros {
+            let span = if !span.from_expansion() || tcx.sess.opts.unstable_opts.debug_macros {
                 span
             } else {
                 // Walk up the macro expansion chain until we reach a non-expanded span.
diff --git a/src/driver/aot.rs b/src/driver/aot.rs
index 05457ce15e9..3cd1ef5639e 100644
--- a/src/driver/aot.rs
+++ b/src/driver/aot.rs
@@ -33,7 +33,7 @@ fn make_module(sess: &Session, isa: Box<dyn TargetIsa>, name: String) -> ObjectM
     // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
     // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
     // can easily double the amount of time necessary to perform linking.
-    builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false));
+    builder.per_function_section(sess.opts.unstable_opts.function_sections.unwrap_or(false));
     ObjectModule::new(builder)
 }
 
@@ -66,7 +66,11 @@ fn emit_module(
     let work_product = if backend_config.disable_incr_cache {
         None
     } else {
-        rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(tcx.sess, &name, &tmp_file)
+        rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
+            tcx.sess,
+            &name,
+            &[("o", &tmp_file)],
+        )
     };
 
     ModuleCodegenResult(
@@ -82,7 +86,10 @@ fn reuse_workproduct_for_cgu(
 ) -> CompiledModule {
     let work_product = cgu.previous_work_product(tcx);
     let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
-    let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &work_product.saved_file);
+    let source_file = rustc_incremental::in_incr_comp_dir_sess(
+        &tcx.sess,
+        &work_product.saved_files.get("o").expect("no saved object file in work product"),
+    );
     if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
         tcx.sess.err(&format!(
             "unable to copy {} to {}: {}",
diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs
index 6937e658ed5..4b2207f3758 100644
--- a/src/intrinsics/mod.rs
+++ b/src/intrinsics/mod.rs
@@ -58,7 +58,6 @@ pub(crate) use llvm::codegen_llvm_intrinsic_call;
 use rustc_middle::ty::print::with_no_trimmed_paths;
 use rustc_middle::ty::subst::SubstsRef;
 use rustc_span::symbol::{kw, sym, Symbol};
-use rustc_target::abi::InitKind;
 
 use crate::prelude::*;
 use cranelift_codegen::ir::AtomicRmwOp;
@@ -672,12 +671,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
                 return;
             }
 
-            if intrinsic == sym::assert_zero_valid
-                && !layout.might_permit_raw_init(
-                    fx,
-                    InitKind::Zero,
-                    fx.tcx.sess.opts.debugging_opts.strict_init_checks) {
-
+            if intrinsic == sym::assert_zero_valid && !fx.tcx.permits_zero_init(layout) {
                 with_no_trimmed_paths!({
                     crate::base::codegen_panic(
                         fx,
@@ -688,12 +682,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
                 return;
             }
 
-            if intrinsic == sym::assert_uninit_valid
-                && !layout.might_permit_raw_init(
-                    fx,
-                    InitKind::Uninit,
-                    fx.tcx.sess.opts.debugging_opts.strict_init_checks) {
-
+            if intrinsic == sym::assert_uninit_valid && !fx.tcx.permits_uninit_init(layout) {
                 with_no_trimmed_paths!({
                     crate::base::codegen_panic(
                         fx,
diff --git a/src/lib.rs b/src/lib.rs
index dfbe7211845..568bb20a3f4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -79,7 +79,7 @@ mod prelude {
     pub(crate) use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout};
     pub(crate) use rustc_middle::ty::{
         self, FloatTy, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut,
-        TypeFoldable, UintTy,
+        TypeFoldable, TypeVisitable, UintTy,
     };
     pub(crate) use rustc_target::abi::{Abi, Scalar, Size, VariantIdx};
 
@@ -171,7 +171,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
         }
     }
 
-    fn target_features(&self, _sess: &Session) -> Vec<rustc_span::Symbol> {
+    fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
         vec![]
     }
 
diff --git a/src/value_and_place.rs b/src/value_and_place.rs
index a68225de58b..8ff35d2f76d 100644
--- a/src/value_and_place.rs
+++ b/src/value_and_place.rs
@@ -615,6 +615,14 @@ impl<'tcx> CPlace<'tcx> {
         }
     }
 
+    pub(crate) fn place_opaque_cast(
+        self,
+        fx: &mut FunctionCx<'_, '_, 'tcx>,
+        ty: Ty<'tcx>,
+    ) -> CPlace<'tcx> {
+        CPlace { inner: self.inner, layout: fx.layout_of(ty) }
+    }
+
     pub(crate) fn place_field(
         self,
         fx: &mut FunctionCx<'_, '_, 'tcx>,