Don't try to remove assignments in SimplifyComparisonIntegral#158214
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Dead store elimination runs a second time after this pass, so leaving assignments around is not an issue. @bors r+ |
Don't try to remove assignments in SimplifyComparisonIntegral The pass tried to opportunistically clean up an unnecessary assign statement if there's no other use of the comparison folded into a `switchInt`. The reasoning was that `switchInt(move _N)` prevents uses of `_N` in other blocks. The immediate problem is that the pass didn't check for other uses of the comparison result *in the same block*. This PR drops the cleanup logic entirely to fix rust-lang#158206. One could try to salvage the cleanup by doing another scan through the basic block and looking for other uses of the temporary. However, the other half of the reasoning (`move` prevents later uses) is also dubious. As the documentation of `Operand::Move` says: > This may additionally overwrite the place with uninit bytes, depending on how we decide in [UCG#188](rust-lang/unsafe-code-guidelines#188). You should not emit MIR that may attempt a subsequent second load of this place without first re-initializing it. This does not justify assuming "moves makes place uninitialized" semantics for the purpose of optimizations. At least for now, it doesn't seem possible to do this cleanup soundly without a whole-function analysis that looks at all uses, i.e., a general dead code elimination pass.
|
I've nominated this for beta and stable backport since I think #158206 has high severity. |
…uwer Rollup of 9 pull requests Successful merges: - #156356 (bootstrap: add bootstrap step to run intrinsic-test in CI) - #157711 (Move proc-macro dlopen from proc-macro-srv to rustc_metadata) - #157836 (rebuild LLVM when `bootstrap.toml` config changes) - #158214 (Don't try to remove assignments in SimplifyComparisonIntegral) - #158226 (miri subtree update) - #158108 (Update actions/download-artifact action to v8.0.1) - #158150 (Update backtrace submodule to pick up AIX related fixes.) - #158178 (Use the target checking infrastructure for the diagnostic attributes) - #158195 (Add me to some rotation groups)
|
beta backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them. |
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#156356 (bootstrap: add bootstrap step to run intrinsic-test in CI) - rust-lang/rust#157711 (Move proc-macro dlopen from proc-macro-srv to rustc_metadata) - rust-lang/rust#157836 (rebuild LLVM when `bootstrap.toml` config changes) - rust-lang/rust#158214 (Don't try to remove assignments in SimplifyComparisonIntegral) - rust-lang/rust#158226 (miri subtree update) - rust-lang/rust#158108 (Update actions/download-artifact action to v8.0.1) - rust-lang/rust#158150 (Update backtrace submodule to pick up AIX related fixes.) - rust-lang/rust#158178 (Use the target checking infrastructure for the diagnostic attributes) - rust-lang/rust#158195 (Add me to some rotation groups)
…uwer Rollup of 9 pull requests Successful merges: - rust-lang/rust#156356 (bootstrap: add bootstrap step to run intrinsic-test in CI) - rust-lang/rust#157711 (Move proc-macro dlopen from proc-macro-srv to rustc_metadata) - rust-lang/rust#157836 (rebuild LLVM when `bootstrap.toml` config changes) - rust-lang/rust#158214 (Don't try to remove assignments in SimplifyComparisonIntegral) - rust-lang/rust#158226 (miri subtree update) - rust-lang/rust#158108 (Update actions/download-artifact action to v8.0.1) - rust-lang/rust#158150 (Update backtrace submodule to pick up AIX related fixes.) - rust-lang/rust#158178 (Use the target checking infrastructure for the diagnostic attributes) - rust-lang/rust#158195 (Add me to some rotation groups)
|
stable backport approved as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle. Backport labels are handled by them. |
|
for #158228 @rust-timer build 6fd92a3 |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (6fd92a3): comparison URL. Overall result: ✅ improvements - 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 3.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 480.522s -> 498.187s (3.68%) |
[stable] 1.96.1 release This prepares 1.96.1 release with: - [Cargo: fix timeout/retry behavior](rust-lang/cargo#17131) - [rustc: fix unsoundness in MIR opt](#158214) Currently targeting this Thursday. r? me
The pass tried to opportunistically clean up an unnecessary assign statement if there's no other use of the comparison folded into a
switchInt. The reasoning was thatswitchInt(move _N)prevents uses of_Nin other blocks. The immediate problem is that the pass didn't check for other uses of the comparison result in the same block. This PR drops the cleanup logic entirely to fix #158206.One could try to salvage the cleanup by doing another scan through the basic block and looking for other uses of the temporary. However, the other half of the reasoning (
moveprevents later uses) is also dubious. As the documentation ofOperand::Movesays:This does not justify assuming "moves makes place uninitialized" semantics for the purpose of optimizations. At least for now, it doesn't seem possible to do this cleanup soundly without a whole-function analysis that looks at all uses, i.e., a general dead code elimination pass.