Skip to content

Commit

Permalink
Mark simplify_aggregate_to_copy mir-opt as unsound
Browse files Browse the repository at this point in the history
Mark the `simplify_aggregate_to_copy` mir-opt added in
<#128299>.

This **partially** reverts commit
e7386b3,
reversing changes made to 02b1be1. The
implementation is just marked as unsound, but the test changes are
reverted.
  • Loading branch information
jieyouxu committed Oct 30, 2024
1 parent 8a90123 commit 4010d46
Show file tree
Hide file tree
Showing 27 changed files with 50 additions and 1,542 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_mir_transform/src/gvn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
}
}

if let AggregateTy::Def(_, _) = ty
// unsound: https://github.com/rust-lang/rust/issues/132353
if tcx.sess.opts.unstable_opts.unsound_mir_opts
&& let AggregateTy::Def(_, _) = ty
&& let Some(value) =
self.simplify_aggregate_to_copy(rvalue, location, &fields, variant_index)
{
Expand Down
40 changes: 0 additions & 40 deletions tests/codegen/clone_as_copy.rs

This file was deleted.

6 changes: 2 additions & 4 deletions tests/codegen/enum/unreachable_enum_default_branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ pub fn implicit_match(x: Int) -> bool {
// The code is from https://github.com/rust-lang/rust/issues/110097.
// We expect it to generate the same optimized code as a full match.
// CHECK-LABEL: @if_let(
// CHECK: start:
// CHECK-NOT: zext
// CHECK: select
// CHECK-NEXT: start:
// CHECK-NEXT: insertvalue
// CHECK-NEXT: insertvalue
// CHECK-NEXT: ret
#[no_mangle]
pub fn if_let(val: Result<i32, ()>) -> Result<i32, ()> {
if let Ok(x) = val { Ok(x * 2) } else { Err(()) }
if let Ok(x) = val { Ok(x) } else { Err(()) }
}
17 changes: 0 additions & 17 deletions tests/mir-opt/gvn_clone.rs

This file was deleted.

71 changes: 0 additions & 71 deletions tests/mir-opt/gvn_clone.{impl#0}-clone.GVN.diff

This file was deleted.

53 changes: 0 additions & 53 deletions tests/mir-opt/gvn_copy_aggregate.all_copy.GVN.diff

This file was deleted.

64 changes: 0 additions & 64 deletions tests/mir-opt/gvn_copy_aggregate.all_copy_2.GVN.diff

This file was deleted.

53 changes: 0 additions & 53 deletions tests/mir-opt/gvn_copy_aggregate.all_copy_different_type.GVN.diff

This file was deleted.

54 changes: 0 additions & 54 deletions tests/mir-opt/gvn_copy_aggregate.all_copy_has_changed.GVN.diff

This file was deleted.

Loading

0 comments on commit 4010d46

Please sign in to comment.