From ac4d0965bb8cbab327cd26306ba4de2036d7d0fd Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 18 Oct 2023 17:40:14 +0000 Subject: [PATCH] FileCheck const_prop_miscompile. --- .../indirect_mutation.bar.ConstProp.diff} | 0 .../indirect_mutation.foo.ConstProp.diff} | 0 tests/mir-opt/const_prop/indirect_mutation.rs | 41 +++++++++++++++++++ tests/mir-opt/const_prop_miscompile.rs | 24 ----------- 4 files changed, 41 insertions(+), 24 deletions(-) rename tests/mir-opt/{const_prop_miscompile.bar.ConstProp.diff => const_prop/indirect_mutation.bar.ConstProp.diff} (100%) rename tests/mir-opt/{const_prop_miscompile.foo.ConstProp.diff => const_prop/indirect_mutation.foo.ConstProp.diff} (100%) create mode 100644 tests/mir-opt/const_prop/indirect_mutation.rs delete mode 100644 tests/mir-opt/const_prop_miscompile.rs diff --git a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff similarity index 100% rename from tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff rename to tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff diff --git a/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff similarity index 100% rename from tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff rename to tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff diff --git a/tests/mir-opt/const_prop/indirect_mutation.rs b/tests/mir-opt/const_prop/indirect_mutation.rs new file mode 100644 index 0000000000000..ec9da6e8e5c5e --- /dev/null +++ b/tests/mir-opt/const_prop/indirect_mutation.rs @@ -0,0 +1,41 @@ +// unit-test: ConstProp +// Check that we do not propagate past an indirect mutation. +#![feature(raw_ref_op)] + +// EMIT_MIR indirect_mutation.foo.ConstProp.diff +fn foo() { + // CHECK-LABEL: fn foo( + // CHECK: debug u => _1; + // CHECK: debug y => _3; + // CHECK: _1 = (const 1_i32,); + // CHECK: _2 = &mut (_1.0: i32); + // CHECK: (*_2) = const 5_i32; + // CHECK: _4 = (_1.0: i32); + // CHECK: _3 = Eq(move _4, const 5_i32); + + let mut u = (1,); + *&mut u.0 = 5; + let y = { u.0 } == 5; +} + +// EMIT_MIR indirect_mutation.bar.ConstProp.diff +fn bar() { + // CHECK-LABEL: fn bar( + // CHECK: debug v => _1; + // CHECK: debug y => _4; + // CHECK: _3 = &raw mut (_1.0: i32); + // CHECK: (*_3) = const 5_i32; + // CHECK: _5 = (_1.0: i32); + // CHECK: _4 = Eq(move _5, const 5_i32); + + let mut v = (1,); + unsafe { + *&raw mut v.0 = 5; + } + let y = { v.0 } == 5; +} + +fn main() { + foo(); + bar(); +} diff --git a/tests/mir-opt/const_prop_miscompile.rs b/tests/mir-opt/const_prop_miscompile.rs deleted file mode 100644 index 00696535ac159..0000000000000 --- a/tests/mir-opt/const_prop_miscompile.rs +++ /dev/null @@ -1,24 +0,0 @@ -// skip-filecheck -// unit-test: ConstProp -#![feature(raw_ref_op)] - -// EMIT_MIR const_prop_miscompile.foo.ConstProp.diff -fn foo() { - let mut u = (1,); - *&mut u.0 = 5; - let y = { u.0 } == 5; -} - -// EMIT_MIR const_prop_miscompile.bar.ConstProp.diff -fn bar() { - let mut v = (1,); - unsafe { - *&raw mut v.0 = 5; - } - let y = { v.0 } == 5; -} - -fn main() { - foo(); - bar(); -}