diff options
| author | bors <bors@rust-lang.org> | 2023-10-29 14:50:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-29 14:50:53 +0000 |
| commit | 83c9732e0c7e1cae5f039677da4c51ee1d9b19b0 (patch) | |
| tree | 05a5ad6943e6dfd98522bf54b83b9fa18386190a /src | |
| parent | 160fd3ceb5143100d4e06f324b02af1f9e786372 (diff) | |
| parent | 24be43356e31d6b0ee2ec8bf912c0a325f236a1d (diff) | |
| download | rust-83c9732e0c7e1cae5f039677da4c51ee1d9b19b0.tar.gz rust-83c9732e0c7e1cae5f039677da4c51ee1d9b19b0.zip | |
Auto merge of #116270 - cjgillot:gvn-aggregate, r=oli-obk,RalfJung
See through aggregates in GVN
This PR is extracted from https://github.com/rust-lang/rust/pull/111344
The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later `SimplifyLocals` do it. This makes tests easier to read (among others).
The next 3 commits add a constant folding mechanism to the GVN pass, presented in https://github.com/rust-lang/rust/pull/116012. ~This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.~
The following commits implement opportunistic simplifications, in particular:
- projections of aggregates: `MyStruct { x: a }.x` gets replaced by `a`, works with enums too;
- projections of arrays: `[a, b][0]` becomes `a`;
- projections of repeat expressions: `[a; N][x]` becomes `a`;
- transform arrays of equal operands into a repeat rvalue.
Fixes https://github.com/rust-lang/miri/issues/3090
r? `@oli-obk`
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/tests/pass/function_pointers.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/tools/miri/tests/pass/function_pointers.rs b/src/tools/miri/tests/pass/function_pointers.rs index 1c99a96feda..36679b7180a 100644 --- a/src/tools/miri/tests/pass/function_pointers.rs +++ b/src/tools/miri/tests/pass/function_pointers.rs @@ -80,9 +80,8 @@ fn main() { // but Miri currently uses a fixed address for monomorphic functions. assert!(return_fn_ptr(i) == i); assert!(return_fn_ptr(i) as unsafe fn() -> i32 == i as fn() -> i32 as unsafe fn() -> i32); - // We don't check anything for `f`. Miri gives it many different addresses - // but mir-opts can turn them into the same address. - let _val = return_fn_ptr(f) != f; + // Miri gives different addresses to different reifications of a generic function. + assert!(return_fn_ptr(f) != f); // However, if we only turn `f` into a function pointer and use that pointer, // it is equal to itself. let f2 = f as fn() -> i32; |
