Skip to content
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

Centralize live loans maintenance to fix scope differences due to liveness #118175

Merged
merged 5 commits into from
Dec 2, 2023

Conversation

lqd
Copy link
Member

@lqd lqd commented Nov 22, 2023

As found in the recent polonius crater run, NLLs and the location-insensitive polonius computed different scopes on some specific CFG shapes, e.g. the following.

image

I had missed that liveness data was pushed from different sources than just the liveness computation: there are a few places that do this -- and some of them may be unneeded or at the very least untested, as no tests changed when I tried removing some of them.

Here, _6 is e.g. dead on entry to bb2[0] during liveness::trace, but its regions will be marked as live later during "constraint generation" (which I plan to refactor away and put in the liveness module soon). This should cause the inflowing loans to be marked live, but they were only computed in liveness::trace.

Therefore, this PR moves live loan maintenance to LivenessValues, so that the various places pushing liveness data will all also update live loans at the same time -- except for promoteds which I don't believe need them, and their liveness handling is already interesting/peculiar.

All the regressions I saw in the initial crater run were related to this kind of shapes, and this change did fix all of them on the next run.

r? @matthewjasper

(This will conflict with #117880 but whichever lands first is fine by me, the end goal is the same for both)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 22, 2023
@bors

This comment was marked as resolved.

@lqd lqd force-pushed the unify-live-loans branch from b5b0002 to 3328432 Compare November 26, 2023 12:00
@bors

This comment was marked as resolved.

@lqd lqd force-pushed the unify-live-loans branch from 3328432 to 1666165 Compare November 27, 2023 07:26
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 1, 2023
…=matthewjasper

Refactor NLL constraint generation and most of polonius fact generation

As discussed in rust-lang#118175, NLL "constraint generation" is only about liveness, but currently also contains legacy polonius fact generation. The latter is quite messy, and this PR cleans this up to prepare for its future removal:

- splits polonius fact generation out of NLL constraint generation
- merges NLL constraint generation to its more natural place, liveness
- extracts all of the polonius fact generation from NLLs apart from MIR typeck (as fact generation is somewhat in a single place there already, but should be cleaned up) into its own explicit module, with a single entry point instead of many.

There should be no behavior changes, and tests seem to behave the same as master: without polonius, with legacy polonius, with the in-tree polonius.

I've split everything into smaller logical commits for easier review, as it required quite a bit of code to be split and moved around, but it should all be trivial changes.

r? `@matthewjasper`
lqd added 5 commits December 1, 2023 14:02
for consistency with how they're named everywhere else
Liveness data is pushed from multiple parts of NLL. Instead of changing
the call sites to maintain live loans, move the latter to `LivenessValues` where
this liveness data is pushed to, and maintain live loans there.

This fixes the differences in polonius scopes on some CFGs where a
variable was dead in tracing but as a MIR terminator its regions were marked
live from "constraint generation"
@bors

This comment was marked as resolved.

@lqd lqd force-pushed the unify-live-loans branch from 1666165 to de2b8b1 Compare December 1, 2023 14:51
@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Dec 1, 2023

📌 Commit de2b8b1 has been approved by matthewjasper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2023
@bors
Copy link
Contributor

bors commented Dec 2, 2023

⌛ Testing commit de2b8b1 with merge bd3a221...

@bors
Copy link
Contributor

bors commented Dec 2, 2023

☀️ Test successful - checks-actions
Approved by: matthewjasper
Pushing bd3a221 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 2, 2023
@bors bors merged commit bd3a221 into rust-lang:master Dec 2, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 2, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bd3a221): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.1% [-2.1%, -2.1%] 1

Cycles

Results

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.9% [-0.9%, -0.9%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 672.846s -> 672.083s (-0.11%)
Artifact size: 313.94 MiB -> 313.95 MiB (0.00%)

@lqd lqd deleted the unify-live-loans branch December 2, 2023 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants