Skip to content

Commit cff5eed

Browse files
committed
Sync from rust 8804161
2 parents b8aab37 + 33b297a commit cff5eed

File tree

11 files changed

+48
-61
lines changed

11 files changed

+48
-61
lines changed

example/issue-91827-extern-types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Regression test for issue #91827.
77

88
#![feature(const_ptr_offset_from)]
9-
#![feature(const_slice_from_raw_parts)]
109
#![feature(extern_types)]
1110

1211
use std::ptr::addr_of;

patches/0027-sysroot-128bit-atomic-operations.patch

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ index 092b7cf..158cf71 100644
1919
#[stable(feature = "integer_atomics_stable", since = "1.34.0")]
2020
impl RefUnwindSafe for crate::sync::atomic::AtomicI64 {}
2121
-#[cfg(target_has_atomic_load_store = "128")]
22-
-#[unstable(feature = "integer_atomics", issue = "32976")]
22+
-#[unstable(feature = "integer_atomics", issue = "99069")]
2323
-impl RefUnwindSafe for crate::sync::atomic::AtomicI128 {}
2424

2525
#[cfg(target_has_atomic_load_store = "ptr")]
@@ -29,7 +29,7 @@ index 092b7cf..158cf71 100644
2929
#[stable(feature = "integer_atomics_stable", since = "1.34.0")]
3030
impl RefUnwindSafe for crate::sync::atomic::AtomicU64 {}
3131
-#[cfg(target_has_atomic_load_store = "128")]
32-
-#[unstable(feature = "integer_atomics", issue = "32976")]
32+
-#[unstable(feature = "integer_atomics", issue = "99069")]
3333
-impl RefUnwindSafe for crate::sync::atomic::AtomicU128 {}
3434

3535
#[cfg(target_has_atomic_load_store = "8")]
@@ -46,14 +46,14 @@ index d9de37e..8293fce 100644
4646
-atomic_int! {
4747
- cfg(target_has_atomic = "128"),
4848
- cfg(target_has_atomic_equal_alignment = "128"),
49-
- unstable(feature = "integer_atomics", issue = "32976"),
50-
- unstable(feature = "integer_atomics", issue = "32976"),
51-
- unstable(feature = "integer_atomics", issue = "32976"),
52-
- unstable(feature = "integer_atomics", issue = "32976"),
53-
- unstable(feature = "integer_atomics", issue = "32976"),
54-
- unstable(feature = "integer_atomics", issue = "32976"),
49+
- unstable(feature = "integer_atomics", issue = "99069"),
50+
- unstable(feature = "integer_atomics", issue = "99069"),
51+
- unstable(feature = "integer_atomics", issue = "99069"),
52+
- unstable(feature = "integer_atomics", issue = "99069"),
53+
- unstable(feature = "integer_atomics", issue = "99069"),
54+
- unstable(feature = "integer_atomics", issue = "99069"),
5555
- rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
56-
- unstable(feature = "integer_atomics", issue = "32976"),
56+
- unstable(feature = "integer_atomics", issue = "99069"),
5757
- cfg_attr(not(test), rustc_diagnostic_item = "AtomicI128"),
5858
- "i128",
5959
- "#![feature(integer_atomics)]\n\n",
@@ -66,14 +66,14 @@ index d9de37e..8293fce 100644
6666
-atomic_int! {
6767
- cfg(target_has_atomic = "128"),
6868
- cfg(target_has_atomic_equal_alignment = "128"),
69-
- unstable(feature = "integer_atomics", issue = "32976"),
70-
- unstable(feature = "integer_atomics", issue = "32976"),
71-
- unstable(feature = "integer_atomics", issue = "32976"),
72-
- unstable(feature = "integer_atomics", issue = "32976"),
73-
- unstable(feature = "integer_atomics", issue = "32976"),
74-
- unstable(feature = "integer_atomics", issue = "32976"),
69+
- unstable(feature = "integer_atomics", issue = "99069"),
70+
- unstable(feature = "integer_atomics", issue = "99069"),
71+
- unstable(feature = "integer_atomics", issue = "99069"),
72+
- unstable(feature = "integer_atomics", issue = "99069"),
73+
- unstable(feature = "integer_atomics", issue = "99069"),
74+
- unstable(feature = "integer_atomics", issue = "99069"),
7575
- rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
76-
- unstable(feature = "integer_atomics", issue = "32976"),
76+
- unstable(feature = "integer_atomics", issue = "99069"),
7777
- cfg_attr(not(test), rustc_diagnostic_item = "AtomicU128"),
7878
- "u128",
7979
- "#![feature(integer_atomics)]\n\n",

src/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn codegen(
2424
unwind_context,
2525
kind,
2626
tcx.lang_items().oom().is_some(),
27-
tcx.sess.opts.debugging_opts.oom,
27+
tcx.sess.opts.unstable_opts.oom,
2828
);
2929
true
3030
} else {

src/base.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,11 @@ fn codegen_stmt<'tcx>(
530530
let val = codegen_operand(fx, operand);
531531
lval.write_cvalue(fx, val);
532532
}
533+
Rvalue::CopyForDeref(place) => {
534+
let cplace = codegen_place(fx, place);
535+
let val = cplace.to_cvalue(fx);
536+
lval.write_cvalue(fx, val)
537+
}
533538
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
534539
let place = codegen_place(fx, place);
535540
let ref_ = place.place_ref(fx, lval.layout());
@@ -662,29 +667,6 @@ fn codegen_stmt<'tcx>(
662667
let (ptr, _extra) = operand.load_scalar_pair(fx);
663668
lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout))
664669
}
665-
} else if let ty::Adt(adt_def, _substs) = from_ty.kind() {
666-
// enum -> discriminant value
667-
assert!(adt_def.is_enum());
668-
match to_ty.kind() {
669-
ty::Uint(_) | ty::Int(_) => {}
670-
_ => unreachable!("cast adt {} -> {}", from_ty, to_ty),
671-
}
672-
let to_clif_ty = fx.clif_type(to_ty).unwrap();
673-
674-
let discriminant = crate::discriminant::codegen_get_discriminant(
675-
fx,
676-
operand,
677-
fx.layout_of(operand.layout().ty.discriminant_ty(fx.tcx)),
678-
)
679-
.load_scalar(fx);
680-
681-
let res = crate::cast::clif_intcast(
682-
fx,
683-
discriminant,
684-
to_clif_ty,
685-
to_ty.is_signed(),
686-
);
687-
lval.write_cvalue(fx, CValue::by_val(res, dest_layout));
688670
} else {
689671
let to_clif_ty = fx.clif_type(to_ty).unwrap();
690672
let from = operand.load_scalar(fx);
@@ -862,6 +844,7 @@ pub(crate) fn codegen_place<'tcx>(
862844
PlaceElem::Deref => {
863845
cplace = cplace.place_deref(fx);
864846
}
847+
PlaceElem::OpaqueCast(ty) => cplace = cplace.place_opaque_cast(fx, ty),
865848
PlaceElem::Field(field, _ty) => {
866849
cplace = cplace.place_field(fx, field);
867850
}

src/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(crate) fn clif_int_or_float_cast(
144144
fx.bcx.ins().fcvt_to_uint_sat(to_ty, from)
145145
};
146146

147-
if let Some(false) = fx.tcx.sess.opts.debugging_opts.saturating_float_casts {
147+
if let Some(false) = fx.tcx.sess.opts.unstable_opts.saturating_float_casts {
148148
return val;
149149
}
150150

src/constant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
167167
}
168168

169169
match const_val {
170+
ConstValue::ZeroSized => unreachable!(), // we already handles ZST above
170171
ConstValue::Scalar(x) => match x {
171172
Scalar::Int(int) => {
172173
if fx.clif_type(layout.ty).is_some() {

src/debuginfo/line_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'tcx> DebugContext<'tcx> {
140140
// In order to have a good line stepping behavior in debugger, we overwrite debug
141141
// locations of macro expansions with that of the outermost expansion site
142142
// (unless the crate is being compiled with `-Z debug-macros`).
143-
let span = if !span.from_expansion() || tcx.sess.opts.debugging_opts.debug_macros {
143+
let span = if !span.from_expansion() || tcx.sess.opts.unstable_opts.debug_macros {
144144
span
145145
} else {
146146
// Walk up the macro expansion chain until we reach a non-expanded span.

src/driver/aot.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn make_module(sess: &Session, isa: Box<dyn TargetIsa>, name: String) -> ObjectM
3333
// Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
3434
// is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
3535
// can easily double the amount of time necessary to perform linking.
36-
builder.per_function_section(sess.opts.debugging_opts.function_sections.unwrap_or(false));
36+
builder.per_function_section(sess.opts.unstable_opts.function_sections.unwrap_or(false));
3737
ObjectModule::new(builder)
3838
}
3939

@@ -66,7 +66,11 @@ fn emit_module(
6666
let work_product = if backend_config.disable_incr_cache {
6767
None
6868
} else {
69-
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(tcx.sess, &name, &tmp_file)
69+
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
70+
tcx.sess,
71+
&name,
72+
&[("o", &tmp_file)],
73+
)
7074
};
7175

7276
ModuleCodegenResult(
@@ -82,7 +86,10 @@ fn reuse_workproduct_for_cgu(
8286
) -> CompiledModule {
8387
let work_product = cgu.previous_work_product(tcx);
8488
let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
85-
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &work_product.saved_file);
89+
let source_file = rustc_incremental::in_incr_comp_dir_sess(
90+
&tcx.sess,
91+
&work_product.saved_files.get("o").expect("no saved object file in work product"),
92+
);
8693
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
8794
tcx.sess.err(&format!(
8895
"unable to copy {} to {}: {}",

src/intrinsics/mod.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ pub(crate) use llvm::codegen_llvm_intrinsic_call;
5858
use rustc_middle::ty::print::with_no_trimmed_paths;
5959
use rustc_middle::ty::subst::SubstsRef;
6060
use rustc_span::symbol::{kw, sym, Symbol};
61-
use rustc_target::abi::InitKind;
6261

6362
use crate::prelude::*;
6463
use cranelift_codegen::ir::AtomicRmwOp;
@@ -672,12 +671,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
672671
return;
673672
}
674673

675-
if intrinsic == sym::assert_zero_valid
676-
&& !layout.might_permit_raw_init(
677-
fx,
678-
InitKind::Zero,
679-
fx.tcx.sess.opts.debugging_opts.strict_init_checks) {
680-
674+
if intrinsic == sym::assert_zero_valid && !fx.tcx.permits_zero_init(layout) {
681675
with_no_trimmed_paths!({
682676
crate::base::codegen_panic(
683677
fx,
@@ -688,12 +682,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
688682
return;
689683
}
690684

691-
if intrinsic == sym::assert_uninit_valid
692-
&& !layout.might_permit_raw_init(
693-
fx,
694-
InitKind::Uninit,
695-
fx.tcx.sess.opts.debugging_opts.strict_init_checks) {
696-
685+
if intrinsic == sym::assert_uninit_valid && !fx.tcx.permits_uninit_init(layout) {
697686
with_no_trimmed_paths!({
698687
crate::base::codegen_panic(
699688
fx,

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod prelude {
7979
pub(crate) use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout};
8080
pub(crate) use rustc_middle::ty::{
8181
self, FloatTy, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut,
82-
TypeFoldable, UintTy,
82+
TypeFoldable, TypeVisitable, UintTy,
8383
};
8484
pub(crate) use rustc_target::abi::{Abi, Scalar, Size, VariantIdx};
8585

@@ -171,7 +171,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
171171
}
172172
}
173173

174-
fn target_features(&self, _sess: &Session) -> Vec<rustc_span::Symbol> {
174+
fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
175175
vec![]
176176
}
177177

src/value_and_place.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,14 @@ impl<'tcx> CPlace<'tcx> {
615615
}
616616
}
617617

618+
pub(crate) fn place_opaque_cast(
619+
self,
620+
fx: &mut FunctionCx<'_, '_, 'tcx>,
621+
ty: Ty<'tcx>,
622+
) -> CPlace<'tcx> {
623+
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
624+
}
625+
618626
pub(crate) fn place_field(
619627
self,
620628
fx: &mut FunctionCx<'_, '_, 'tcx>,

0 commit comments

Comments
 (0)