GVN: Use the borrows only if they are always live#147886
GVN: Use the borrows only if they are always live#147886dianqk wants to merge 5 commits intorust-lang:mainfrom
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| /// Check that we allow dereferences in the RHS if the LHS is a stable projection. | ||
| // This introduces copy overlapping if dereferencing `_2` or `_4`. | ||
| #[custom_mir(dialect = "runtime")] | ||
| fn stable_projection(_1: (Adt,)) { |
There was a problem hiding this comment.
@cjgillot I just found this still introduces copy overlapping.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
GVN: Only introduce new derefs if the immutable borrow is always valid.
This comment has been minimized.
This comment has been minimized.
|
I'd have kept introducing |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (efb5f98): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 4.1%, secondary 0.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 472.659s -> 474.116s (0.31%) |
Oh, I think this is a great insight. IIUC, I can remove |
c0cb50a to
3870535
Compare
Hmm, I still need to handle this in Actually, that's not enough. |
This comment has been minimized.
This comment has been minimized.
3870535 to
eac4cc9
Compare
8bf926b to
c8fbb62
Compare
This comment has been minimized.
This comment has been minimized.
I changed it to forbid introducing borrows outside their lifetime. And c8fbb62 should fix #130853. I have another experimental patch, 6e2ecde, using live variables, but this may introduce miscompile, and I won't add it. @rustbot review |
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
GVN: Use the borrows only if they are always live
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (2b9aa76): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.2%, secondary 1.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.2%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary 0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 471.42s -> 472.371s (0.20%) |
d6f8232 to
3665eaa
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot author |
|
I realized that we are propagating the borrows of non-SSA locals. This is why we use borrows outside their lifetime. |
|
☔ The latest upstream changes (presumably #150925) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Superseded by #150485. |
Fixes #141313 and #141313 (comment). This PR forbids introducing borrows outside their lifetime.
c8fbb62 fixes #130853.
I agree with what #147844 (comment) mentioned:
r? cjgillot