Skip to content

Commit 8d8a46e

Browse files
committed
Remove unsound-mir-opts for simplify_aggregate_to_copy
1 parent b2f02df commit 8d8a46e

File tree

4 files changed

+29
-43
lines changed

4 files changed

+29
-43
lines changed

compiler/rustc_mir_transform/src/gvn.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
10811081
}
10821082
}
10831083

1084-
// unsound: https://github.com/rust-lang/rust/issues/132353
1085-
if tcx.sess.opts.unstable_opts.unsound_mir_opts
1086-
&& let AggregateTy::Def(_, _) = ty
1084+
if let AggregateTy::Def(_, _) = ty
10871085
&& let Some(value) =
10881086
self.simplify_aggregate_to_copy(rvalue, location, &fields, variant_index)
10891087
{

tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ fn old(_1: Result<T, E>) -> Result<T, E> {
1919
}
2020

2121
bb1: {
22-
_3 = move ((_1 as Ok).0: T);
23-
_0 = Result::<T, E>::Ok(copy _3);
22+
_3 = copy ((_1 as Ok).0: T);
23+
_0 = copy _1;
2424
goto -> bb3;
2525
}
2626

2727
bb2: {
28-
_4 = move ((_1 as Err).0: E);
29-
_0 = Result::<T, E>::Err(copy _4);
28+
_4 = copy ((_1 as Err).0: E);
29+
_0 = copy _1;
3030
goto -> bb3;
3131
}
3232

tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-abort.mir

+12-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
77
debug self => _1;
88
scope 2 (inlined Vec::<u8>::as_slice) {
99
debug self => _1;
10-
let mut _7: usize;
10+
let mut _6: usize;
1111
scope 3 (inlined Vec::<u8>::as_ptr) {
1212
debug self => _1;
1313
let mut _2: &alloc::raw_vec::RawVec<u8>;
@@ -16,7 +16,6 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
1616
let mut _3: &alloc::raw_vec::RawVecInner;
1717
scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::<u8>) {
1818
debug self => _3;
19-
let mut _6: std::ptr::NonNull<u8>;
2019
scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::<u8>) {
2120
debug self => _3;
2221
let mut _4: std::ptr::NonNull<u8>;
@@ -32,20 +31,20 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
3231
}
3332
}
3433
scope 10 (inlined Unique::<u8>::as_non_null_ptr) {
35-
debug ((self: Unique<u8>).0: std::ptr::NonNull<u8>) => _6;
34+
debug ((self: Unique<u8>).0: std::ptr::NonNull<u8>) => _4;
3635
debug ((self: Unique<u8>).1: std::marker::PhantomData<u8>) => const PhantomData::<u8>;
3736
}
3837
}
3938
scope 11 (inlined NonNull::<u8>::as_ptr) {
40-
debug self => _6;
39+
debug self => _4;
4140
}
4241
}
4342
}
4443
}
4544
scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) {
4645
debug data => _5;
47-
debug len => _7;
48-
let _8: *const [u8];
46+
debug len => _6;
47+
let _7: *const [u8];
4948
scope 13 (inlined core::ub_checks::check_language_ub) {
5049
scope 14 (inlined core::ub_checks::check_language_ub::runtime) {
5150
}
@@ -56,10 +55,10 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
5655
}
5756
scope 17 (inlined slice_from_raw_parts::<u8>) {
5857
debug data => _5;
59-
debug len => _7;
58+
debug len => _6;
6059
scope 18 (inlined std::ptr::from_raw_parts::<[u8], u8>) {
6160
debug data_pointer => _5;
62-
debug metadata => _7;
61+
debug metadata => _6;
6362
}
6463
}
6564
}
@@ -71,22 +70,17 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
7170
_2 = &((*_1).0: alloc::raw_vec::RawVec<u8>);
7271
StorageLive(_3);
7372
_3 = &(((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner);
74-
StorageLive(_6);
75-
StorageLive(_4);
7673
_4 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
7774
_5 = copy (_4.0: *const u8);
78-
_6 = NonNull::<u8> { pointer: copy _5 };
79-
StorageDead(_4);
80-
StorageDead(_6);
8175
StorageDead(_3);
8276
StorageDead(_2);
77+
StorageLive(_6);
78+
_6 = copy ((*_1).1: usize);
8379
StorageLive(_7);
84-
_7 = copy ((*_1).1: usize);
85-
StorageLive(_8);
86-
_8 = *const [u8] from (copy _5, copy _7);
87-
_0 = &(*_8);
88-
StorageDead(_8);
80+
_7 = *const [u8] from (copy _5, copy _6);
81+
_0 = &(*_7);
8982
StorageDead(_7);
83+
StorageDead(_6);
9084
return;
9185
}
9286
}

tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir

+12-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
77
debug self => _1;
88
scope 2 (inlined Vec::<u8>::as_slice) {
99
debug self => _1;
10-
let mut _7: usize;
10+
let mut _6: usize;
1111
scope 3 (inlined Vec::<u8>::as_ptr) {
1212
debug self => _1;
1313
let mut _2: &alloc::raw_vec::RawVec<u8>;
@@ -16,7 +16,6 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
1616
let mut _3: &alloc::raw_vec::RawVecInner;
1717
scope 5 (inlined alloc::raw_vec::RawVecInner::ptr::<u8>) {
1818
debug self => _3;
19-
let mut _6: std::ptr::NonNull<u8>;
2019
scope 6 (inlined alloc::raw_vec::RawVecInner::non_null::<u8>) {
2120
debug self => _3;
2221
let mut _4: std::ptr::NonNull<u8>;
@@ -32,20 +31,20 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
3231
}
3332
}
3433
scope 10 (inlined Unique::<u8>::as_non_null_ptr) {
35-
debug ((self: Unique<u8>).0: std::ptr::NonNull<u8>) => _6;
34+
debug ((self: Unique<u8>).0: std::ptr::NonNull<u8>) => _4;
3635
debug ((self: Unique<u8>).1: std::marker::PhantomData<u8>) => const PhantomData::<u8>;
3736
}
3837
}
3938
scope 11 (inlined NonNull::<u8>::as_ptr) {
40-
debug self => _6;
39+
debug self => _4;
4140
}
4241
}
4342
}
4443
}
4544
scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) {
4645
debug data => _5;
47-
debug len => _7;
48-
let _8: *const [u8];
46+
debug len => _6;
47+
let _7: *const [u8];
4948
scope 13 (inlined core::ub_checks::check_language_ub) {
5049
scope 14 (inlined core::ub_checks::check_language_ub::runtime) {
5150
}
@@ -56,10 +55,10 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
5655
}
5756
scope 17 (inlined slice_from_raw_parts::<u8>) {
5857
debug data => _5;
59-
debug len => _7;
58+
debug len => _6;
6059
scope 18 (inlined std::ptr::from_raw_parts::<[u8], u8>) {
6160
debug data_pointer => _5;
62-
debug metadata => _7;
61+
debug metadata => _6;
6362
}
6463
}
6564
}
@@ -71,22 +70,17 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
7170
_2 = &((*_1).0: alloc::raw_vec::RawVec<u8>);
7271
StorageLive(_3);
7372
_3 = &(((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner);
74-
StorageLive(_6);
75-
StorageLive(_4);
7673
_4 = copy (((((*_1).0: alloc::raw_vec::RawVec<u8>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
7774
_5 = copy (_4.0: *const u8);
78-
_6 = NonNull::<u8> { pointer: copy _5 };
79-
StorageDead(_4);
80-
StorageDead(_6);
8175
StorageDead(_3);
8276
StorageDead(_2);
77+
StorageLive(_6);
78+
_6 = copy ((*_1).1: usize);
8379
StorageLive(_7);
84-
_7 = copy ((*_1).1: usize);
85-
StorageLive(_8);
86-
_8 = *const [u8] from (copy _5, copy _7);
87-
_0 = &(*_8);
88-
StorageDead(_8);
80+
_7 = *const [u8] from (copy _5, copy _6);
81+
_0 = &(*_7);
8982
StorageDead(_7);
83+
StorageDead(_6);
9084
return;
9185
}
9286
}

0 commit comments

Comments
 (0)