rust
rust copied to clipboard
mir-opt: Merge all branch BBs into a single copy statement
#128299 simplified
match a {
Foo::A(x) => Foo::A(*x),
Foo::B => Foo::B
}
to
match a {
Foo::A(x) => a, // copy a
Foo::B => Foo::B
}
The switch branch can be simplified into a single copy statement. This PR implements a relatively general simplification.
r? @nnethercote
rustbot has assigned @nnethercote. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
r? ghost
Failed to set assignee to ghost: invalid assignee
Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.
r? cjgillot
The job mingw-check-tidy failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
--stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#13 2.904 Building wheels for collected packages: reuse
#13 2.905 Building wheel for reuse (pyproject.toml): started
#13 3.155 Building wheel for reuse (pyproject.toml): finished with status 'done'
#13 3.157 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#13 3.157 Stored in directory: /tmp/pip-ephem-wheel-cache-3id33myr/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#13 3.159 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#13 3.559 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#13 3.560 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#13 4.097 Collecting virtualenv
#13 4.097 Collecting virtualenv
#13 4.153 Downloading virtualenv-20.26.3-py3-none-any.whl (5.7 MB)
#13 4.383 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 MB 24.9 MB/s eta 0:00:00
#13 4.446 Collecting filelock<4,>=3.12.2
#13 4.454 Downloading filelock-3.15.4-py3-none-any.whl (16 kB)
#13 4.488 Collecting platformdirs<5,>=3.9.1
#13 4.496 Downloading platformdirs-4.2.2-py3-none-any.whl (18 kB)
#13 4.518 Collecting distlib<1,>=0.3.7
#13 4.537 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 KB 49.3 MB/s eta 0:00:00
#13 4.537 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 KB 49.3 MB/s eta 0:00:00
#13 4.618 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#13 4.807 Successfully installed distlib-0.3.8 filelock-3.15.4 platformdirs-4.2.2 virtualenv-20.26.3
#13 DONE 4.9s
#14 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#14 DONE 0.0s
---
DirectMap4k: 184256 kB
DirectMap2M: 7155712 kB
DirectMap1G: 11534336 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://ci-artifacts.rust-lang.org/rustc-builds-alt/d6c8169c186ab16a3404cd0d0866674018e8a19e/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
extracting /checkout/obj/build/cache/llvm-d6c8169c186ab16a3404cd0d0866674018e8a19e-true/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz to /checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm
---
Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
Finished `release` profile [optimized] target(s) in 28.97s
##[endgroup]
fmt check
Diff in /checkout/tests/mir-opt/match_br/match_br_merge_copy.rs:70:
// CHECK-NEXT return;
match a {
Some(_b) => a,
+ None => None,
}
}
Diff in /checkout/tests/mir-opt/match_br/match_br_merge_copy.rs:84:
Some(_) => {
Some(_) => {
*b = 1;
- },
- None => None
+ }
+ None => None,
+ None => None,
}
}
fmt error: Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/tests/mir-opt/building/match/match_false_edges.rs" "/checkout/tests/mir-opt/building/match/simple_match.rs" "/checkout/tests/mir-opt/building/match/exponential_or.rs" "/checkout/tests/mir-opt/building/issue_110508.rs" "/checkout/tests/mir-opt/building/eq_never_type.rs" "/checkout/tests/mir-opt/building/storage_live_dead_in_statics.rs" "/checkout/tests/mir-opt/building/receiver_ptr_mutability.rs" "/checkout/tests/mir-opt/building/logical_or_in_conditional.rs" "/checkout/tests/mir-opt/match_br/match_br_merge_copy.rs" "/checkout/tests/mir-opt/byte_slice.rs" "/checkout/tests/mir-opt/switch_to_self.rs" "/checkout/tests/mir-opt/issue_78192.rs" "/checkout/tests/mir-opt/coroutine_storage_dead_unwind.rs" "/checkout/tests/mir-opt/reference_prop.rs" "/checkout/tests/mir-opt/issue_38669.rs" "/checkout/tests/mir-opt/issue_101973.rs" "/checkout/tests/mir-opt/remove_storage_markers.rs" "/checkout/tests/mir-opt/inline_coroutine_body.rs" "/checkout/tests/mir-opt/issue_72181.rs" "/checkout/tests/mir-opt/retag.rs" "/checkout/tests/mir-opt/lower_intrinsics.rs" "/checkout/tests/mir-opt/issue_72181_1.rs" "/checkout/tests/mir-opt/unreachable_enum_branching.rs" "/checkout/tests/mir-opt/no_drop_for_inactive_variant.rs" "/checkout/tests/mir-opt/issue_120925_unsafefncast.rs" "/checkout/tests/mir-opt/lower_slice_len.rs" "/checkout/tests/mir-opt/remove_unneeded_drops.rs" "/checkout/tests/coverage-run-rustdoc/auxiliary/doctest_crate.rs" "/checkout/tests/coverage-run-rustdoc/doctest.rs" "/checkout/tests/rustdoc-js/search-short-types.rs" "/checkout/tests/rustdoc-js/never-search.rs" "/checkout/tests/rustdoc-js/doc-alias.rs" "/checkout/tests/rustdoc-js/trait-methods.rs" "/checkout/tests/rustdoc-js/non-english-identifier.rs" "/checkout/tests/rustdoc-js/foreign-type-path.rs" "/checkout/tests/rustdoc-js/doc-alias-whitespace.rs" "/checkout/tests/rustdoc-js/raw-pointer.rs" "/checkout/tests/rustdoc-js/assoc-type-backtrack.rs" "/checkout/tests/rustdoc-js/summaries.rs" "/checkout/tests/rustdoc-js/enum-variant-not-type.rs" "/checkout/tests/rustdoc-js/generics-trait.rs" "/checkout/tests/rustdoc-js/underscoredtype.rs" "/checkout/tests/rustdoc-js/reexport-dedup.rs" "/checkout/tests/rustdoc-js/self-is-not-generic.rs" "/checkout/tests/rustdoc-js/tuple-unit.rs" "/checkout/tests/rustdoc-js/generics.rs" "/checkout/tests/rustdoc-js/search-non-local-trait-impl.rs" "/checkout/tests/rustdoc-js/reexport.rs" "/checkout/tests/rustdoc-js/assoc-type-loop.rs" "/checkout/tests/rustdoc-js/auxiliary/macro-in-module.rs" "/checkout/tests/rustdoc-js/auxiliary/interner.rs" "/checkout/tests/rustdoc-js/auxiliary/equivalent.rs" "/checkout/tests/rustdoc-js/looks-like-rustc-interner.rs" "/checkout/tests/rustdoc-js/search-bag-semantics.rs" "/checkout/tests/rustdoc-js/struct-like-variant.rs" "/checkout/tests/rustdoc-js/nested-unboxed.rs" "/checkout/tests/rustdoc-js/generics-nested.rs" "/checkout/tests/rustdoc-js/primitive.rs" "/checkout/tests/rustdoc-js/doc-alias-filter-out.rs" "/checkout/tests/rustdoc-js/generics-multi-trait.rs" "/checkout/tests/rustdoc-js/generics-impl.rs" "/checkout/tests/rustdoc-js/path-maxeditdistance.rs" "/checkout/tests/rustdoc-js/type-parameters.rs" "/checkout/tests/mir-opt/building/match/never_patterns.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
local time: Tue Sep 3 13:50:55 UTC 2024
network time: Tue, 03 Sep 2024 13:50:55 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
:umbrella: The latest upstream changes (presumably #128299) made this pull request unmergeable. Please resolve the merge conflicts.
@bors try @rust-timer queue
Awaiting bors try build completion.
@rustbot label: +S-waiting-on-perf
:hourglass: Trying commit 622247a04b8286df0e72a5f5dfa34dd74807b254 with merge c3241126e94d7a53a1805ad854686e0bd061b5df...
:sunny: Try build successful - checks-actions
Build commit: c3241126e94d7a53a1805ad854686e0bd061b5df (c3241126e94d7a53a1805ad854686e0bd061b5df)
Queued c3241126e94d7a53a1805ad854686e0bd061b5df with parent 5e3ede22ef6fd23197629c22b9f466b3734e19f1, future comparison URL. There is currently 1 preceding artifact in the queue. It will probably take at least ~2.3 hours until the benchmark run finishes.
Finished benchmarking commit (c3241126e94d7a53a1805ad854686e0bd061b5df): comparison URL.
Overall result: no relevant changes - no action needed
Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.
@bors rollup=never @rustbot label: -S-waiting-on-perf -perf-regression
Instruction count
This benchmark run did not return any relevant results for this metric.
Max RSS (memory usage)
Results (primary 0.9%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
4.0% | [3.0%, 5.1%] | 3 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-3.8% | [-5.9%, -1.7%] | 2 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 0.9% | [-5.9%, 5.1%] | 5 |
Cycles
This benchmark run did not return any relevant results for this metric.
Binary size
Results (primary 0.0%, secondary -0.0%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
0.1% | [0.0%, 0.2%] | 11 |
| Regressions ❌ (secondary) |
0.0% | [0.0%, 0.1%] | 2 |
| Improvements ✅ (primary) |
-0.1% | [-0.3%, -0.0%] | 6 |
| Improvements ✅ (secondary) |
-0.0% | [-0.0%, -0.0%] | 3 |
| All ❌✅ (primary) | 0.0% | [-0.3%, 0.2%] | 17 |
Bootstrap: 760.71s -> 756.595s (-0.54%) Artifact size: 341.13 MiB -> 341.17 MiB (0.01%)
* for clone impls, use some kind of `StructuralClone` trait so that we fully replace the derived impls `Clone` with simpler MIR; * for general MIR, lift the restrictions on this pass (bb0 and assignment to _0 namely).What do you think?
It looks like makes sense.
IIUC, the StructuralClone is exact matching clone shims? I expect this can improve compile-time.
@rustbot author
Some changes occurred to MIR optimizations
cc @rust-lang/wg-mir-opt
@bors try @rust-timer queue
Awaiting bors try build completion.
@rustbot label: +S-waiting-on-perf
:hourglass: Trying commit dddf04628e1e3e9ecc51b06d3791c65ebbc4ba3f with merge 366e98f4a5ed3bd1a9882e096b12eba79e126ddc...
:sunny: Try build successful - checks-actions
Build commit: 366e98f4a5ed3bd1a9882e096b12eba79e126ddc (366e98f4a5ed3bd1a9882e096b12eba79e126ddc)
Queued 366e98f4a5ed3bd1a9882e096b12eba79e126ddc with parent 5a4ee43c387110736440cecc375cb5aedc441dbc, future comparison URL. There is currently 1 preceding artifact in the queue. It will probably take at least ~1.2 hours until the benchmark run finishes.
Finished benchmarking commit (366e98f4a5ed3bd1a9882e096b12eba79e126ddc): comparison URL.
Overall result: ❌ regressions - ACTION NEEDED
Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.
Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.
@bors rollup=never @rustbot label: -S-waiting-on-perf +perf-regression
Instruction count
This is a highly reliable metric that was used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
0.4% | [0.2%, 0.8%] | 6 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 0.4% | [0.2%, 0.8%] | 6 |
Max RSS (memory usage)
Results (primary 2.8%, secondary -3.1%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
2.8% | [2.3%, 3.4%] | 3 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-3.1% | [-3.1%, -3.1%] | 1 |
| All ❌✅ (primary) | 2.8% | [2.3%, 3.4%] | 3 |
Cycles
Results (secondary -1.8%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
- | - | 0 |
| Regressions ❌ (secondary) |
2.0% | [2.0%, 2.0%] | 1 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-2.5% | [-2.6%, -2.3%] | 6 |
| All ❌✅ (primary) | - | - | 0 |
Binary size
Results (primary -0.0%, secondary -0.0%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
0.3% | [0.1%, 0.4%] | 3 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-0.1% | [-0.4%, -0.0%] | 8 |
| Improvements ✅ (secondary) |
-0.0% | [-0.0%, -0.0%] | 1 |
| All ❌✅ (primary) | -0.0% | [-0.4%, 0.4%] | 11 |
Bootstrap: 774.178s -> 775.458s (0.17%) Artifact size: 342.23 MiB -> 342.33 MiB (0.03%)
@bors try @rust-timer queue
Awaiting bors try build completion.
@rustbot label: +S-waiting-on-perf
:hourglass: Trying commit 7846743c0a2634d6eba9889a5b411307f792fbde with merge 963788449d01d434fa9a69b331e4f5c41f10eab4...
:sunny: Try build successful - checks-actions
Build commit: 963788449d01d434fa9a69b331e4f5c41f10eab4 (963788449d01d434fa9a69b331e4f5c41f10eab4)
Queued 963788449d01d434fa9a69b331e4f5c41f10eab4 with parent 68301a6a968326bac8b85b04d5ef7e79cc042a00, future comparison URL. There are currently 0 preceding artifacts in the queue. It will probably take at least ~1.5 hours until the benchmark run finishes.
Finished benchmarking commit (963788449d01d434fa9a69b331e4f5c41f10eab4): comparison URL.
Overall result: ❌✅ regressions and improvements - no action needed
Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.
@bors rollup=never @rustbot label: -S-waiting-on-perf -perf-regression
Instruction count
This is a highly reliable metric that was used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
0.5% | [0.3%, 0.8%] | 2 |
| Regressions ❌ (secondary) |
0.5% | [0.5%, 0.5%] | 1 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
-0.5% | [-0.5%, -0.5%] | 1 |
| All ❌✅ (primary) | 0.5% | [0.3%, 0.8%] | 2 |
Max RSS (memory usage)
Results (primary 3.2%, secondary 2.5%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
3.2% | [2.2%, 4.7%] | 4 |
| Regressions ❌ (secondary) |
2.5% | [2.5%, 2.5%] | 1 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 3.2% | [2.2%, 4.7%] | 4 |
Cycles
Results (primary 1.9%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
1.9% | [1.0%, 2.8%] | 2 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
- | - | 0 |
| Improvements ✅ (secondary) |
- | - | 0 |
| All ❌✅ (primary) | 1.9% | [1.0%, 2.8%] | 2 |
Binary size
Results (primary -0.0%, secondary -0.0%)
This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
| mean | range | count | |
|---|---|---|---|
| Regressions ❌ (primary) |
0.3% | [0.1%, 0.4%] | 3 |
| Regressions ❌ (secondary) |
- | - | 0 |
| Improvements ✅ (primary) |
-0.1% | [-0.4%, -0.0%] | 8 |
| Improvements ✅ (secondary) |
-0.0% | [-0.0%, -0.0%] | 1 |
| All ❌✅ (primary) | -0.0% | [-0.4%, 0.4%] | 11 |
Bootstrap: 775.25s -> 775.189s (-0.01%) Artifact size: 329.52 MiB -> 329.45 MiB (-0.02%)
@rustbot review
I will probably update in two days.
@rustbot author
Just a few trivial modifications and rebase.
I have tried to update the document and DSE.
@rustbot review