-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[nll] optimize redundant reborrows #53176
Comments
Let me leave a few notes here. I'm not 100% sure on what changes are needed, but this is the general vicinity. We compute the "set of all borrows" into this
In that data structure, we currently walk over the MIR and identify assignments of borrows (e.g., rust/src/librustc_mir/borrow_check/borrow_set.rs Lines 162 to 164 in ccb550f
An 'unsafe place' is something like the deref of a raw pointer: I think we basically want to rename /// Returns true if we can safely ignore borrows of this place.
/// This is true whenever there is no action that the user can do
/// to the place `self` that would invalidate the borrow. This is true
/// for borrows of raw pointer dereferents as well as shared references.
fn ignore_borrow_of(&self) -> bool {
...
} then we will add [ rust/src/librustc_mir/borrow_check/place_ext.rs Lines 42 to 45 in ccb550f
Specifically, |
So, I couldnt' help myself. I had a few minutes and that changed seemed so easy that I gave it a spin. |
…g-values, r=pnkfelix optimize redundant borrows and escaping paths in NLL This builds on #53168 and adds a commit that addresses #53176 -- or at least I think it does. I marked this as WIP because I want to see the test results (and measure the performance). I also want to double check we're not adding in any unsoundness here.
…g-values, r=pnkfelix optimize redundant borrows and escaping paths in NLL This builds on #53168 and adds a commit that addresses #53176 -- or at least I think it does. I marked this as WIP because I want to see the test results (and measure the performance). I also want to double check we're not adding in any unsoundness here.
This was completed in #53177 |
When you have a borrow like this:
where
y: &T
, then there is really no reason for the borrow checker to "record" the borrow or figure out its scope. The reason is that there is no action that one can do withy
that would invalidatex
. (Of course we still want to record the outlives relationship that forcesy
's lifetime to outlivex
's lifetime.)The old AST borrow checker did this same optimization. It ought to have a huge effect on html5ever: my profile measurements suggest that basically all of its time is spent with these very large borrow sets.
The text was updated successfully, but these errors were encountered: