Sync from rust 880416180b0a9ee1141c07d4d17667edb77daebd

This commit is contained in:
bjorn3 2022-07-18 12:10:52 +02:00
commit cff5eed8ef
11 changed files with 48 additions and 61 deletions

View File

@ -6,7 +6,6 @@
// Regression test for issue #91827. // Regression test for issue #91827.
#![feature(const_ptr_offset_from)] #![feature(const_ptr_offset_from)]
#![feature(const_slice_from_raw_parts)]
#![feature(extern_types)] #![feature(extern_types)]
use std::ptr::addr_of; use std::ptr::addr_of;

View File

@ -19,7 +19,7 @@ index 092b7cf..158cf71 100644
#[stable(feature = "integer_atomics_stable", since = "1.34.0")] #[stable(feature = "integer_atomics_stable", since = "1.34.0")]
impl RefUnwindSafe for crate::sync::atomic::AtomicI64 {} impl RefUnwindSafe for crate::sync::atomic::AtomicI64 {}
-#[cfg(target_has_atomic_load_store = "128")] -#[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 {} -impl RefUnwindSafe for crate::sync::atomic::AtomicI128 {}
#[cfg(target_has_atomic_load_store = "ptr")] #[cfg(target_has_atomic_load_store = "ptr")]
@ -29,7 +29,7 @@ index 092b7cf..158cf71 100644
#[stable(feature = "integer_atomics_stable", since = "1.34.0")] #[stable(feature = "integer_atomics_stable", since = "1.34.0")]
impl RefUnwindSafe for crate::sync::atomic::AtomicU64 {} impl RefUnwindSafe for crate::sync::atomic::AtomicU64 {}
-#[cfg(target_has_atomic_load_store = "128")] -#[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 {} -impl RefUnwindSafe for crate::sync::atomic::AtomicU128 {}
#[cfg(target_has_atomic_load_store = "8")] #[cfg(target_has_atomic_load_store = "8")]
@ -46,14 +46,14 @@ index d9de37e..8293fce 100644
-atomic_int! { -atomic_int! {
- cfg(target_has_atomic = "128"), - cfg(target_has_atomic = "128"),
- cfg(target_has_atomic_equal_alignment = "128"), - cfg(target_has_atomic_equal_alignment = "128"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), - 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"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
- "i128", - "i128",
- "#![feature(integer_atomics)]\n\n", - "#![feature(integer_atomics)]\n\n",
@ -66,14 +66,14 @@ index d9de37e..8293fce 100644
-atomic_int! { -atomic_int! {
- cfg(target_has_atomic = "128"), - cfg(target_has_atomic = "128"),
- cfg(target_has_atomic_equal_alignment = "128"), - cfg(target_has_atomic_equal_alignment = "128"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "99069"),
- rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"), - 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"), - cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
- "u128", - "u128",
- "#![feature(integer_atomics)]\n\n", - "#![feature(integer_atomics)]\n\n",

View File

@ -24,7 +24,7 @@ pub(crate) fn codegen(
unwind_context, unwind_context,
kind, kind,
tcx.lang_items().oom().is_some(), tcx.lang_items().oom().is_some(),
tcx.sess.opts.debugging_opts.oom, tcx.sess.opts.unstable_opts.oom,
); );
true true
} else { } else {

View File

@ -530,6 +530,11 @@ fn codegen_stmt<'tcx>(
let val = codegen_operand(fx, operand); let val = codegen_operand(fx, operand);
lval.write_cvalue(fx, val); 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) => { Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
let place = codegen_place(fx, place); let place = codegen_place(fx, place);
let ref_ = place.place_ref(fx, lval.layout()); let ref_ = place.place_ref(fx, lval.layout());
@ -662,29 +667,6 @@ fn codegen_stmt<'tcx>(
let (ptr, _extra) = operand.load_scalar_pair(fx); let (ptr, _extra) = operand.load_scalar_pair(fx);
lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout)) 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 { } else {
let to_clif_ty = fx.clif_type(to_ty).unwrap(); let to_clif_ty = fx.clif_type(to_ty).unwrap();
let from = operand.load_scalar(fx); let from = operand.load_scalar(fx);
@ -862,6 +844,7 @@ pub(crate) fn codegen_place<'tcx>(
PlaceElem::Deref => { PlaceElem::Deref => {
cplace = cplace.place_deref(fx); cplace = cplace.place_deref(fx);
} }
PlaceElem::OpaqueCast(ty) => cplace = cplace.place_opaque_cast(fx, ty),
PlaceElem::Field(field, _ty) => { PlaceElem::Field(field, _ty) => {
cplace = cplace.place_field(fx, field); cplace = cplace.place_field(fx, field);
} }

View File

@ -144,7 +144,7 @@ pub(crate) fn clif_int_or_float_cast(
fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) 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; return val;
} }

View File

@ -167,6 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
} }
match const_val { match const_val {
ConstValue::ZeroSized => unreachable!(), // we already handles ZST above
ConstValue::Scalar(x) => match x { ConstValue::Scalar(x) => match x {
Scalar::Int(int) => { Scalar::Int(int) => {
if fx.clif_type(layout.ty).is_some() { if fx.clif_type(layout.ty).is_some() {

View File

@ -140,7 +140,7 @@ impl<'tcx> DebugContext<'tcx> {
// In order to have a good line stepping behavior in debugger, we overwrite debug // 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 // locations of macro expansions with that of the outermost expansion site
// (unless the crate is being compiled with `-Z debug-macros`). // (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 span
} else { } else {
// Walk up the macro expansion chain until we reach a non-expanded span. // Walk up the macro expansion chain until we reach a non-expanded span.

View File

@ -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 // 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 // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
// can easily double the amount of time necessary to perform linking. // 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) ObjectModule::new(builder)
} }
@ -66,7 +66,11 @@ fn emit_module(
let work_product = if backend_config.disable_incr_cache { let work_product = if backend_config.disable_incr_cache {
None None
} else { } 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( ModuleCodegenResult(
@ -82,7 +86,10 @@ fn reuse_workproduct_for_cgu(
) -> CompiledModule { ) -> CompiledModule {
let work_product = cgu.previous_work_product(tcx); let work_product = cgu.previous_work_product(tcx);
let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str())); 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) { if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
tcx.sess.err(&format!( tcx.sess.err(&format!(
"unable to copy {} to {}: {}", "unable to copy {} to {}: {}",

View File

@ -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::print::with_no_trimmed_paths;
use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::subst::SubstsRef;
use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::symbol::{kw, sym, Symbol};
use rustc_target::abi::InitKind;
use crate::prelude::*; use crate::prelude::*;
use cranelift_codegen::ir::AtomicRmwOp; use cranelift_codegen::ir::AtomicRmwOp;
@ -672,12 +671,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
return; return;
} }
if intrinsic == sym::assert_zero_valid if intrinsic == sym::assert_zero_valid && !fx.tcx.permits_zero_init(layout) {
&& !layout.might_permit_raw_init(
fx,
InitKind::Zero,
fx.tcx.sess.opts.debugging_opts.strict_init_checks) {
with_no_trimmed_paths!({ with_no_trimmed_paths!({
crate::base::codegen_panic( crate::base::codegen_panic(
fx, fx,
@ -688,12 +682,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
return; return;
} }
if intrinsic == sym::assert_uninit_valid if intrinsic == sym::assert_uninit_valid && !fx.tcx.permits_uninit_init(layout) {
&& !layout.might_permit_raw_init(
fx,
InitKind::Uninit,
fx.tcx.sess.opts.debugging_opts.strict_init_checks) {
with_no_trimmed_paths!({ with_no_trimmed_paths!({
crate::base::codegen_panic( crate::base::codegen_panic(
fx, fx,

View File

@ -79,7 +79,7 @@ mod prelude {
pub(crate) use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout}; pub(crate) use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout};
pub(crate) use rustc_middle::ty::{ pub(crate) use rustc_middle::ty::{
self, FloatTy, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut, self, FloatTy, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut,
TypeFoldable, UintTy, TypeFoldable, TypeVisitable, UintTy,
}; };
pub(crate) use rustc_target::abi::{Abi, Scalar, Size, VariantIdx}; 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![] vec![]
} }

View File

@ -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( pub(crate) fn place_field(
self, self,
fx: &mut FunctionCx<'_, '_, 'tcx>, fx: &mut FunctionCx<'_, '_, 'tcx>,