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

Encode constraints that hold at all points as logical edges in location-sensitive polonius #135290

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lqd
Copy link
Member

@lqd lqd commented Jan 9, 2025

Currently, with the full setup in #134980 (but is from #134268), the polonius location-sensitive analysis converts Locations::All typeck constraints as edges at all points in the CFG. This was temporary.

There's a FIXME about that already, and this PR implements it: we now use the constraints that hold at all points during traversal instead of eagerly materializing them as physical edges.

Another easy one @jackh726, but it's stacked on top of #134980, only the last two commits are new and of interest here. Once again opening as draft until that other PR lands.

This fixes the slowness that was happening on the big CFG from the saturating-float-casts test (because of its 12M materialized edges) without, AFAICT, simply moving this overhead to traversal: materializing the logical edges is done on-demand.

r? @jackh726 (no rush either)

lqd added 8 commits January 9, 2025 14:24
in NLLs some locals are marked live at all points if one of their
regions escapes the function but that doesn't work in a flow-sensitive
setting like polonius
we're in in the endgame now

set up the location-sensitive analysis end to end:
- stop recording inflowing loans and loan liveness in liveness
- replace location-insensitive liveness data with live loans computed by
  reachability
- remove equivalence between polonius scopes and NLL scopes, and only
  run one scope computation
it's a bit mind-bending
this prepares the code structure for adding logical edges to the graph next
Instead of materializing `Locations::All` constraints as physical edges
at all the points in the CFG, we record them as logical edges and only
materialize them during traversal as successors for a given node.

This fixes the slowness/hang in the `saturating-float-casts.rs` test.
@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 Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants