Replace locals in debuginfo records during ref_prop and dest_prop#147525
Replace locals in debuginfo records during ref_prop and dest_prop#147525bors merged 4 commits intorust-lang:masterfrom
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| location: Location, | ||
| ) { | ||
| if let StmtDebugInfo::AssignRef(local, _) = stmt_debuginfo | ||
| && let Value::Pointer(target, _) = self.targets[*local] |
There was a problem hiding this comment.
If this mirrors visit_var_debug_info, we need an extra condition on target.projection, don't we?
There was a problem hiding this comment.
I think var_debug_info will handle projection. We just need to adjust to the new load.
| - StorageDead(_3); | ||
| - StorageDead(_1); | ||
| + // DBG: _1 = &(*_5); | ||
| + // DBG: _5 = &(*_5); |
There was a problem hiding this comment.
Should we keep this statement, or drop it as a tautology?
There was a problem hiding this comment.
Hmm, I'm not sure. It looks like LLVM doesn't care about what the value is: https://rust.godbolt.org/z/vc3W5fKr4.
|
This doesn't fix the case we saw internally in netlink-proto. Could you also give it a shot against the non-minimized reproducer in #147485? |
Had a few minutes, so I checked: with this PR applied the reproducer in https://github.com/krasimirgg/netlink-proto branch |
|
Assuming the invariant proposed here, the root cause in the original reproducer was in destination propagation (note the replacement of DestinationPropagation diff for protocol::protocol::::handle_response--- ./netlink_proto.protocol-protocol-{impl#1}-handle_response.3-2-028.DestinationPropagation.before.mir 2025-10-09 19:33:36.091255817 +0200
+++ ./netlink_proto.protocol-protocol-{impl#1}-handle_response.3-2-028.DestinationPropagation.after.mir 2025-10-09 19:33:36.093145504 +0200
@@ -1,3 +1,3 @@
-// MIR for `protocol::protocol::<impl at src/protocol/protocol.rs:63:1: 66:22>::handle_response` before DestinationPropagation
+// MIR for `protocol::protocol::<impl at src/protocol/protocol.rs:63:1: 66:22>::handle_response` after DestinationPropagation
fn protocol::protocol::<impl at src/protocol/protocol.rs:63:1: 66:22>::handle_response(_1: &mut VecDeque<Response<T, M>>, _2: std::collections::hash_map::OccupiedEntry<'_, RequestId, PendingRequest<M>>, _3: NetlinkMessage<T>) -> () {
@@ -72,5 +72,5 @@
let mut _5: &protocol::protocol::RequestId;
scope 2 {
- debug request_id => _5;
+ debug request_id => _41;
let _6: log::Level;
let _19: bool;
...
@@ -588,5 +588,5 @@
bb12: {
// DBG: _5 = &((*_78).0: protocol::protocol::RequestId);
- StorageLive(_19);
+ nop;
_20 = discriminant((_3.1: netlink_packet_core::NetlinkPayload<T>));
switchInt(move _20) -> [4: bb2, otherwise: bb1];
...
@@ -664,6 +664,6 @@
_4 = copy _159;
_41 = &_4;
- _5 = copy _41;
- _25 = copy _163;
+ nop;
+ nop;
goto -> bb8;
}
... |
0c0cf47 to
400c56e
Compare
|
This PR was rebased onto a different master 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. |
|
Yes. The local in the statement debuginfo was not updated along with the var debuginfo. This may also mix different debugging variables, then mislead debuginfo. |
| } | ||
| } | ||
|
|
||
| for var_debug_info in &$($mutability)? $body.var_debug_info { |
There was a problem hiding this comment.
I'm not sure if relying on the order of visiting is reasonable.
🥲 Fixed. |
|
|
||
| // EMIT_MIR dest_prop.remap_debuginfo_locals.DestinationPropagation.diff | ||
| #[custom_mir(dialect = "runtime", phase = "post-cleanup")] | ||
| pub fn remap_debuginfo_locals(a: bool, b: &bool) -> &bool { |
There was a problem hiding this comment.
Could you add some filecheck annotations?
400c56e to
1ee2c58
Compare
I think dbg statements should be dropped only when |
TBH, I'm a bit worried by the difficulty to maintain the invariant. For instance if GVN or SingleUseConsts starts replacing some places by constants in But already, r=me with the tests and the changes to ref_prop and dest_prop. |
|
@bors r+ |
Rollup of 12 pull requests Successful merges: - #145651 (Regression test for const promotion with Option<Ordering>) - #145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - #146520 (Promote armv8r-none-eabihf target to Tier 2) - #146522 (Promote armv7a-none-eabihf to Tier 2) - #147289 (Mitigate `thread_local!` shadowing issues) - #147515 (Update rustc-perf submodule) - #147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - #147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - #147544 (Remove StatementKind::Deinit.) - #147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - #147553 (Move `wasm32-wasip3` to the tier 3 table) - #147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - #145651 (Regression test for const promotion with Option<Ordering>) - #145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - #146520 (Promote armv8r-none-eabihf target to Tier 2) - #146522 (Promote armv7a-none-eabihf to Tier 2) - #147289 (Mitigate `thread_local!` shadowing issues) - #147515 (Update rustc-perf submodule) - #147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - #147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - #147544 (Remove StatementKind::Deinit.) - #147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - #147553 (Move `wasm32-wasip3` to the tier 3 table) - #147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang/rust#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang/rust#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang/rust#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang/rust#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang/rust#147515 (Update rustc-perf submodule) - rust-lang/rust#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang/rust#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang/rust#147544 (Remove StatementKind::Deinit.) - rust-lang/rust#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang/rust#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang/rust#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang/rust#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang/rust#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang/rust#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang/rust#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang/rust#147515 (Update rustc-perf submodule) - rust-lang/rust#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang/rust#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang/rust#147544 (Remove StatementKind::Deinit.) - rust-lang/rust#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang/rust#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang/rust#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang#147515 (Update rustc-perf submodule) - rust-lang#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang#147544 (Remove StatementKind::Deinit.) - rust-lang#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang#147515 (Update rustc-perf submodule) - rust-lang#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang#147544 (Remove StatementKind::Deinit.) - rust-lang#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang/rust#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang/rust#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang/rust#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang/rust#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang/rust#147515 (Update rustc-perf submodule) - rust-lang/rust#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang/rust#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang/rust#147544 (Remove StatementKind::Deinit.) - rust-lang/rust#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang/rust#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang/rust#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang/rust#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang/rust#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang/rust#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang/rust#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang/rust#147515 (Update rustc-perf submodule) - rust-lang/rust#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang/rust#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang/rust#147544 (Remove StatementKind::Deinit.) - rust-lang/rust#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang/rust#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang/rust#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang/rust#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang/rust#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang/rust#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang/rust#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang/rust#147515 (Update rustc-perf submodule) - rust-lang/rust#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang/rust#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang/rust#147544 (Remove StatementKind::Deinit.) - rust-lang/rust#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang/rust#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang/rust#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - rust-lang/rust#145651 (Regression test for const promotion with Option<Ordering>) - rust-lang/rust#145722 (implement Extend<{Group, Literal, Punct, Ident}> for TokenStream) - rust-lang/rust#146520 (Promote armv8r-none-eabihf target to Tier 2) - rust-lang/rust#146522 (Promote armv7a-none-eabihf to Tier 2) - rust-lang/rust#147289 (Mitigate `thread_local!` shadowing issues) - rust-lang/rust#147515 (Update rustc-perf submodule) - rust-lang/rust#147522 (compiletest: Use the same directive lines for EarlyProps and ignore/only/needs) - rust-lang/rust#147525 (Replace locals in debuginfo records during ref_prop and dest_prop) - rust-lang/rust#147544 (Remove StatementKind::Deinit.) - rust-lang/rust#147551 (remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`) - rust-lang/rust#147553 (Move `wasm32-wasip3` to the tier 3 table) - rust-lang/rust#147562 (Stabilize `NonZero<u*>::div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
Fixes #147485.
r? cjgillot