Repository navigation
Avoid hoisting uninitialized reads in EarlyOtherwiseBranch - #164864
rust-bors[bot] merged 2 commits into
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Let's pick a reviewer who knows more about MIR opts: r? @dianqk |
The reason for keeping reachable-otherwise cases was to preserve scalar match optimizations. In the earlier codegen checks, one three-way example grew from 20 to 55 bytes with the pass disabled, though that’s only a small example. Skipping these cases would definitely make the fix simpler. Do i keep this PR to that restriction and handle the optimization seperately ? |
I don't see any missing cases in the PR, so we can handle the optimization there. I 'll take another look later. |
|
@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.
…5, r=<try> Avoid hoisting uninitialized reads in EarlyOtherwiseBranch
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (22a54bb): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression 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 -0.9%, secondary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.5%, secondary 0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 490.291s -> 489.287s (-0.20%) |
|
|
@bors r+ |
…ranch-164765, r=dianqk Avoid hoisting uninitialized reads in EarlyOtherwiseBranch Fixes rust-lang#164765. EarlyOtherwiseBranch can hoist a read onto a path where its operand is uninitialized, causing a miscompilation. When the parent’s otherwise branch is reachable, this restricts scalar hoisting to unchanged function arguments and their struct/tuple fields. It reuses VisitPlacesWith to reject writes, borrows, moves, and storage resets, without adding runtime branches. The tradeoff is conservative: some safe computed locals and borrowed or modified arguments lose this optimization. Supporting those cases would require a broader initialization analysis. (any suggestions or pointers here?)
…uwer Rollup of 7 pull requests Successful merges: - #161922 (Tie extern "llvm-intrinsics" and llvm.* symbol names together) - #164864 (Avoid hoisting uninitialized reads in EarlyOtherwiseBranch) - #165854 (Explicitly drop job server helper thread) - #164077 (replace `TypingEnv::post_analysis()` with `mir::Body::typing_env()`) - #165305 (hexagon: pass small aggregates on the stack when registers run out) - #165417 (Mention width limit panic in fmt doc) - #165860 (Fix inverted wasm cfg in core benchmarks)
ah yea right |
a89dd90 to
43dc29b
Compare
|
This pull request was unapproved. This PR was contained in a rollup (#165873), which was closed. |
|
@bors r+ |
…ranch-164765, r=dianqk Avoid hoisting uninitialized reads in EarlyOtherwiseBranch Fixes rust-lang#164765. EarlyOtherwiseBranch can hoist a read onto a path where its operand is uninitialized, causing a miscompilation. When the parent’s otherwise branch is reachable, this restricts scalar hoisting to unchanged function arguments and their struct/tuple fields. It reuses VisitPlacesWith to reject writes, borrows, moves, and storage resets, without adding runtime branches. The tradeoff is conservative: some safe computed locals and borrowed or modified arguments lose this optimization. Supporting those cases would require a broader initialization analysis. (any suggestions or pointers here?)
…uwer Rollup of 18 pull requests Successful merges: - #164828 (When suggesting path of renamed crate, use the renamed name) - #164864 (Avoid hoisting uninitialized reads in EarlyOtherwiseBranch) - #165068 (Change color usage for highlights) - #165221 (Canonicalize more comparison operators) - #165841 (Tell Miri about the alignment handling in the Windows System allocator) - #165869 (Cleanup: Remove `path_matches` and `value_str` from `AttributeExt`) - #165880 (Remove dead code for returning `BackendRepr::Memory` with `PassMode::Direct`) - #164108 (Add unstable `-Zllvm-tpde` flag to `rustc_codegen_llvm`) - #165565 (view-types: lower view types from HIR) - #165622 (small cleanups in rustc_codegen_llvm) - #165745 (Don't ICE when a guard condition is a place of type `!`) - #165771 (tests: cover MSVC ThinLTO exported symbol preservation) - #165810 (reflection: reflect attributes from adts, fields, and variants) - #165823 (Tweak crate error wording and turn them into fatal errors) - #165849 (More opt-dist improvements) - #165855 (Update `sysinfo` version to `0.40.3`) - #165872 (Some attribute related cleanups) - #165905 (CI: Use a consistent locale when sorting docker build inputs)
…uwer Rollup of 17 pull requests Successful merges: - #164828 (When suggesting path of renamed crate, use the renamed name) - #164864 (Avoid hoisting uninitialized reads in EarlyOtherwiseBranch) - #165068 (Change color usage for highlights) - #165221 (Canonicalize more comparison operators) - #165841 (Tell Miri about the alignment handling in the Windows System allocator) - #165869 (Cleanup: Remove `path_matches` and `value_str` from `AttributeExt`) - #165880 (Remove dead code for returning `BackendRepr::Memory` with `PassMode::Direct`) - #164108 (Add unstable `-Zllvm-tpde` flag to `rustc_codegen_llvm`) - #165565 (view-types: lower view types from HIR) - #165622 (small cleanups in rustc_codegen_llvm) - #165771 (tests: cover MSVC ThinLTO exported symbol preservation) - #165810 (reflection: reflect attributes from adts, fields, and variants) - #165823 (Tweak crate error wording and turn them into fatal errors) - #165849 (More opt-dist improvements) - #165855 (Update `sysinfo` version to `0.40.3`) - #165872 (Some attribute related cleanups) - #165905 (CI: Use a consistent locale when sorting docker build inputs)
Rollup merge of #164864 - darkraider01:fix-early-otherwise-branch-164765, r=dianqk Avoid hoisting uninitialized reads in EarlyOtherwiseBranch Fixes #164765. EarlyOtherwiseBranch can hoist a read onto a path where its operand is uninitialized, causing a miscompilation. When the parent’s otherwise branch is reachable, this restricts scalar hoisting to unchanged function arguments and their struct/tuple fields. It reuses VisitPlacesWith to reject writes, borrows, moves, and storage resets, without adding runtime branches. The tradeoff is conservative: some safe computed locals and borrowed or modified arguments lose this optimization. Supporting those cases would require a broader initialization analysis. (any suggestions or pointers here?)
View all comments
Fixes #164765.
EarlyOtherwiseBranch can hoist a read onto a path where its operand is uninitialized, causing a miscompilation.
When the parent’s otherwise branch is reachable, this restricts scalar hoisting to unchanged function arguments and their struct/tuple fields. It reuses VisitPlacesWith to reject writes, borrows, moves, and storage resets, without adding runtime branches.
The tradeoff is conservative: some safe computed locals and borrowed or modified arguments lose this optimization. Supporting those cases would require a broader initialization analysis. (any suggestions or pointers here?)