diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-18 17:40:14 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-31 22:56:02 +0000 |
| commit | ac4d0965bb8cbab327cd26306ba4de2036d7d0fd (patch) | |
| tree | 4ddbbca8095ecf43fb8ea1f3853f9fca4b2fb9d0 | |
| parent | e65ec7d8f1a01a5eec62fb71865f0a124aec1ead (diff) | |
| download | rust-ac4d0965bb8cbab327cd26306ba4de2036d7d0fd.tar.gz rust-ac4d0965bb8cbab327cd26306ba4de2036d7d0fd.zip | |
FileCheck const_prop_miscompile.
| -rw-r--r-- | tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff (renamed from tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff) | 0 | ||||
| -rw-r--r-- | tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff (renamed from tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff) | 0 | ||||
| -rw-r--r-- | tests/mir-opt/const_prop/indirect_mutation.rs | 41 | ||||
| -rw-r--r-- | tests/mir-opt/const_prop_miscompile.rs | 24 |
4 files changed, 41 insertions, 24 deletions
diff --git a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff index 4eafb8d0917..4eafb8d0917 100644 --- a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff +++ b/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 index 445d9895d6a..445d9895d6a 100644 --- a/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff +++ b/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 00000000000..ec9da6e8e5c --- /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 00696535ac1..00000000000 --- 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(); -} |
