-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Introduce debuginfo to statements in MIR #142771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
15c968a
to
6b013d4
Compare
This comment has been minimized.
This comment has been minimized.
6b013d4
to
51576e7
Compare
This comment has been minimized.
This comment has been minimized.
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Introduce debuginfo to statements in MIR Not ready for reviewing. Something known: - [ ] Retain debuginfo when concatenating bbs - [ ] Document about when to drop debuginfos (don't be worse than the optimized LLVM IR) - [ ] Missing tests r? ghost
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (eb83156): 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.3%, secondary 3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.2%, secondary 2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 691.482s -> 692.445s (0.14%) |
51576e7
to
e72c3ae
Compare
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Introduce debuginfo to statements in MIR Not ready for reviewing. Something known: - [ ] Retain debuginfo when concatenating bbs - [ ] Document about when to drop debuginfos (don't be worse than the optimized LLVM IR) - [ ] Missing tests r? ghost
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (77d5c6a): 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.4%, secondary 3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.1%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 690.617s -> 691.47s (0.12%) |
☔ The latest upstream changes (presumably #142870) made this pull request unmergeable. Please resolve the merge conflicts. |
// For `_n = &((*_1).0: i32);`, we are calculating the address of `_1.0`, so | ||
// we should drop the deref projection. | ||
let projected_ty = local_ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really have trouble understanding the logic here. &(*_1).0
and &_1.0
should result in very different code, shouldn't they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are talking about the following code (https://rust.godbolt.org/z/xsdazTs1n):
#[repr(C)]
pub struct Foo(i32, i64, i32);
#[unsafe(no_mangle)]
fn bar(ptr_foo: Foo) -> i32 {
let b = &ptr_foo.1; // &(_1.1: i64);
ptr_foo.2
}
#[unsafe(no_mangle)]
fn foo(ref_foo: &Foo) -> i32 {
let a = &ref_foo.1; // &((*_1).1: i64);
ref_foo.2
}
They are different MIR statements, but they have the same LLVM IR statement due to the ABI of arguments.
Both Foo
and &Foo
are passed as a pointer here.
47cc699
to
e2f9c7e
Compare
This comment has been minimized.
This comment has been minimized.
cc @davidtwco for the debuginfo part, since you are the only debuginfo reviewer now. |
r=me on the MIR part. I don't mind an extra review for the codegen part. |
☔ The latest upstream changes (presumably #146666) made this pull request unmergeable. Please resolve the merge conflicts. |
I am writing some explanations for debugging information, which should help with the review. @rustbot author |
While I was explaining cases one-by-one based on @cjgillot I think you are right, they have the same LLVM IR, however their code logic is very different. It would be easier to understand and maintain if we used The test cases are based on @rustbot review r? cjgillot (for the debuginfo part if you think the new change is fine) |
Requested reviewer is already assigned to this pull request. Please choose another assignee. |
eba7551
to
df5c862
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. |
df5c862
to
8018751
Compare
This comment has been minimized.
This comment has been minimized.
// For an rvalue like `&(*_1).1`, we are calculating the address of `_1.1`, | ||
// so we should drop the deref projection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is wrong. &(*_1).1
means &((*_1).1)
, which is not the same as &(*(_1.1))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, IIUC, the MIR statement of pub fn foo(a: &Foo){ let b = &a.2; }
is _2 = &((*_1).2: i32);
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean calculating the address of (*_1).1
here. _1.1
doesn't exist. That would be the second field of a reference, but references don't have fields.
8018751
to
6c0fd07
Compare
This comment has been minimized.
This comment has been minimized.
6c0fd07
to
844c8a4
Compare
If the `LocalRef` is `LocalRef::Place`, we can refer to it directly, because the local of place is an indirect pointer. Such a statement is `_1 = &(_2.1)`. If the `LocalRef` is `LocalRef::Operand`, the `OperandRef` should provide the pointer of the reference. Such a statement is `_1 = &((*_2).1)`. But there is a special case that hasn't been handled, scalar pairs like `(&[i32; 16], i32)`.
844c8a4
to
8c5a513
Compare
The new change should exactly match |
The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix #128081.
I don't modify Stable MIR, as I don't think we need debug information when using it.
This PR represents the debug information for the dead reference statement via
#dbg_value
. For example,let _foo_b = &foo.b
becomes#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)
. You can see this here: https://rust.godbolt.org/z/d43js6adv.The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR.
The current rules for dropping debug information in this PR are:
I doesn't drop debuginfos in
MatchBranchSimplification
, because LLVM also pick one branch for it.