-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix ElaborateBoxDerefs
on debug varinfo
#128572
Fix ElaborateBoxDerefs
on debug varinfo
#128572
Conversation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
||
let (unique_ty, nonnull_ty, ptr_ty) = | ||
build_ptr_tys(tcx, base_ty.boxed_ty(), unique_did, nonnull_did); | ||
|
||
new_projections.extend_from_slice(&base.projection[last_deref..]); |
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 the problem here has to do with the indexing of this slice (and the other [last_deref..]
below), but I think it was pretty difficult to follow so I simplified the logic to just build up the projections more simply, one at a time.
Rerolling since I'm not familiar with this. r? mir |
Originally I was a bit surprised by this then I started looking at our debuginfo test suite more and now I'm not surprised at all. It's a Christmas Miracle that debuggers work as well with Rust as they do. @bors r+ rollup=iffy |
☀️ Test successful - checks-actions |
A job failed! Check out the build log: (web) (plain) Click to see the possible cause of the failure (guessed by this bot)
|
wtf |
That's https://github.com/rust-lang/rust/blob/730d5d4095a264ef5f7c0a0781eea68c15431d45/.github/workflows/dependencies.yml it must be broken again, or still. |
Finished benchmarking commit (730d5d4): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary 1.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 756.781s -> 757.993s (0.16%) |
Slightly simplifies the
ElaborateBoxDerefs
pass to fix cases where it was applying the wrong projections to debug var infos containing places that deref boxes.From what I can tell1, we don't actually have any tests (or code anywhere, really) that exercise
debug x => *(...: Box<T>)
, and it's very difficult to trigger this in surface Rust, so I wrote a custom MIR test.What happens is that the pass was turning
*(SOME_PLACE: Box<T>)
into*(*((((SOME_PLACE).0: Unique<T>).0: NonNull<T>).0: *const T))
in debug var infos. In particular, notice the double deref, which was wrong.This is the root cause of #128554, so this PR fixes #128554 as well. The reason that async closures was affected is because of the way that we compute the
ByMove
body, which resulted in*(...: Box<T>)
in debug var info. But this really has nothing to do with async closures.Footnotes
Validated by literally replacing the
if elem == PlaceElem::Deref && base_ty.is_box() { ... }
innards with apanic!()
, which compiled all of stage2 without panicking. ↩