Skip to content

Commit 981f9ec

Browse files
committed
Mark simplify_aggregate_to_copy mir-opt as unsound
1 parent 8a90123 commit 981f9ec

10 files changed

+24
-6
lines changed

compiler/rustc_mir_transform/src/gvn.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
10791079
}
10801080
}
10811081

1082-
if let AggregateTy::Def(_, _) = ty
1082+
// unsound: https://github.com/rust-lang/rust/issues/132353
1083+
if tcx.sess.opts.unstable_opts.unsound_mir_opts
1084+
&& let AggregateTy::Def(_, _) = ty
10831085
&& let Some(value) =
10841086
self.simplify_aggregate_to_copy(rvalue, location, &fields, variant_index)
10851087
{

tests/codegen/clone_as_copy.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ revisions: DEBUGINFO NODEBUGINFO
2+
//@ compile-flags: -Zunsound-mir-opts
3+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
24
//@ compile-flags: -O -Cno-prepopulate-passes
35
//@ [DEBUGINFO] compile-flags: -Cdebuginfo=full
46

tests/mir-opt/gvn_clone.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ compile-flags: -Zunsound-mir-opts
2+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
13
//@ test-mir-pass: GVN
24
//@ compile-flags: -Zmir-enable-passes=+InstSimplify-before-inline
35

tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- // MIR for `<impl at $DIR/gvn_clone.rs:12:10: 12:15>::clone` before GVN
2-
+ // MIR for `<impl at $DIR/gvn_clone.rs:12:10: 12:15>::clone` after GVN
1+
- // MIR for `<impl at $DIR/gvn_clone.rs:14:10: 14:15>::clone` before GVN
2+
+ // MIR for `<impl at $DIR/gvn_clone.rs:14:10: 14:15>::clone` after GVN
33

4-
fn <impl at $DIR/gvn_clone.rs:12:10: 12:15>::clone(_1: &AllCopy) -> AllCopy {
4+
fn <impl at $DIR/gvn_clone.rs:14:10: 14:15>::clone(_1: &AllCopy) -> AllCopy {
55
debug self => _1;
66
let mut _0: AllCopy;
77
let mut _2: i32;

tests/mir-opt/gvn_copy_aggregate.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ compile-flags: -Zunsound-mir-opts
2+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353.
13
//@ test-mir-pass: GVN
24
//@ compile-flags: -Cpanic=abort
35

tests/mir-opt/pre-codegen/clone_as_copy.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ compile-flags: -Zunsound-mir-opts
2+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
13
//@ compile-flags: -Cdebuginfo=full
24

35
// Check if we have transformed the nested clone to the copy in the complete pipeline.

tests/mir-opt/pre-codegen/no_inlined_clone.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ compile-flags: -Zunsound-mir-opts
2+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
3+
14
#![crate_type = "lib"]
25

36
// EMIT_MIR no_inlined_clone.{impl#0}-clone.PreCodegen.after.mir

tests/mir-opt/pre-codegen/no_inlined_clone.{impl#0}-clone.PreCodegen.after.mir

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `<impl at $DIR/no_inlined_clone.rs:9:10: 9:15>::clone` after PreCodegen
1+
// MIR for `<impl at $DIR/no_inlined_clone.rs:12:10: 12:15>::clone` after PreCodegen
22

3-
fn <impl at $DIR/no_inlined_clone.rs:9:10: 9:15>::clone(_1: &Foo) -> Foo {
3+
fn <impl at $DIR/no_inlined_clone.rs:12:10: 12:15>::clone(_1: &Foo) -> Foo {
44
debug self => _1;
55
let mut _0: Foo;
66

tests/mir-opt/pre-codegen/try_identity.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ compile-flags: -Zunsound-mir-opts
2+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
3+
14
// skip-filecheck
25
//@ compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
36

tests/mir-opt/pre-codegen/vec_deref.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ compile-flags: -Zunsound-mir-opts
2+
// FIXME: see <https://github.com/rust-lang/rust/issues/132353>
13
// skip-filecheck
24
//@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
35
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY

0 commit comments

Comments
 (0)